【问题标题】:Cannot use Mahapps in plugin project无法在插件项目中使用 Mahapps
【发布时间】:2014-12-22 10:24:47
【问题描述】:

我正在使用 MvvmCross 开发 wpf 应用程序。我有自己的带有警报窗口的对话框插件。当我单击某些按钮以确认我的操作时,它会弹出。以前,警报窗口只是一个简单的 wpf 窗口。但我想用 Mahapps 来设计它。

问题是当我将 AlertWindow 的基类从 window 更改为 Mahapps 的 MetroWindow 时,出现错误“Could not find plugin type in assembly”

下面是我在 xaml 文件和 c# 文件中的代码

<Controls:MetroWindow x:Class="Test.MvvmCross.Plugins.Dialog.Wpf.AlertWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="" Height="120" Width="350" SizeToContent="Height" ShowInTaskbar="False" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" >
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Test.MvvmCross.Plugins.Dialog.Wpf;component/Styles/Generic.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <StackPanel Orientation="Vertical">
        <TextBlock TextWrapping="Wrap" Margin="10" Text="{Binding Message}" Name="MessageTb">asdfasdf asdfasdf asdfa asdfas asdf asdf asdf</TextBlock>
        <DockPanel Margin="5" Background="White">
            <Button DockPanel.Dock="Right" Margin="5" Height="30" Width="65" Name="NeutralButton" IsCancel="True">
                <Grid>
                    <ContentControl Style="{StaticResource Content1NormalButtonStyle}" >
                        <TextBlock Name="NeutralContent1Textblock" Foreground="{StaticResource ButtonNotSelectedColorBrush}"/>
                    </ContentControl>
                    <ContentControl Style="{StaticResource Content2NormalButtonStyle}" >
                        <TextBlock Name="NeutralContent2Textblock" Foreground="{StaticResource ButtonTextColorBrush}" FontWeight="Bold"/>
                    </ContentControl>
                </Grid>
            </Button>
            <Button DockPanel.Dock="Right" Margin="5" Height="30" Width="65" Name="NegativeButton">
                <Grid>
                    <ContentControl Style="{StaticResource Content1NormalButtonStyle}" >
                        <TextBlock Name="NegativeContent1Textblock" Foreground="{StaticResource ButtonNotSelectedColorBrush}"/>
                    </ContentControl>
                    <ContentControl Style="{StaticResource Content2NormalButtonStyle}" >
                        <TextBlock Name="NegativeContent2Textblock" Foreground="{StaticResource ButtonTextColorBrush}" FontWeight="Bold"/>
                    </ContentControl>
                </Grid>
            </Button>
            <Button DockPanel.Dock="Right"  Margin="5" Height="30" Width="65" Name="PositiveButton" IsDefault="True" >
                <Grid>
                    <ContentControl Style="{StaticResource Content1NormalButtonStyle}" >
                        <TextBlock Name="PositiveContent1Textblock" Foreground="{StaticResource ButtonNotSelectedColorBrush}"/>
                    </ContentControl>
                    <ContentControl Name="PositiveContent2" Style="{StaticResource Content2NormalButtonStyle}" >
                        <TextBlock Name="PositiveContent2Textblock" Foreground="{StaticResource ButtonTextColorBrush}" FontWeight="Bold"/>
                    </ContentControl>
                </Grid>
            </Button>
            <Control />
        </DockPanel>
    </StackPanel>
</Controls:MetroWindow>

这是错误消息image

**我已经更新了 xaml 代码

我在我的主要项目中使用了 Mahapps,没有任何问题。如果您不明白我想要什么或其他任何内容,请告诉我。

【问题讨论】:

  • 你能发布确切的错误信息吗?
  • 你在哪里包含Style资源。
  • @Matthew 我不确定你的问题。我将它添加到
  • 消息“在程序集中找不到插件类型”表明查找 Plugin.cs 类的反射失败 - 调试该区域 - 而不是 xaml - 这是我的猜测
  • @Stuart 你能解释一下吗?我也添加了那个类的精确定位,但它没有去那里。

标签: c# wpf xamarin mvvmcross mahapps.metro


【解决方案1】:

我找到了我的问题的解决方案。它是 MahApps 的版本。因为 ui 项目使用的版本比插件项目旧。

在我将它们更改为相同之后,一切都很好。

【讨论】:

    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 1970-01-01
    • 2017-05-23
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 1970-01-01
    相关资源
    最近更新 更多