不能在插件项目中使用Mahapps

时间:2014-12-22 10:24:48

标签: c# wpf xamarin mvvmcross mahapps.metro

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

问题是当我将AlertWindow的基类从窗口更改为Mahapps的MetroWindow时发生错误“无法在程序集中找到插件类型”

下面是我在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没有问题。如果你不明白我想要什么或其他什么,请告诉我。

1 个答案:

答案 0 :(得分:1)

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

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