如何在XAML

时间:2016-02-23 07:59:55

标签: c# wpf xaml prism

我开发了Prism 6 WPF模块化应用程序,我在那里使用了名为“CommonResources”的SharedProject - 请看下面:

enter image description here

这个SharedProject有两个文件夹:'Classes'和'Styles'。在'Styles'文件夹中有'RadiobuttonStyle.xaml'文件和常见的ResourceDictionary文件(用于在我的应用程序中设置RadioButtons的样式)。下面我部分显示ResourceDictionary:

<ResourceDictionary    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:CommonResources.Styles"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                mc:Ignorable="d" 
                xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing">

<!--Style for radiobuttons, used for view-switching-->
<Style x:Key="MainViewRadioButtonStyle" TargetType="RadioButton">
    <Setter Property="Background" Value="{x:Null}"/>
    <Setter Property="Foreground" Value="#FF483D8B"/>
    <Setter Property="Padding" Value="3"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="FontSize" Value="12"/>
    <Setter Property="BorderBrush" Value="#FF6A5ACD" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="RadioButton">
                <Grid>
                . . . . . . . . . . .

我在“授权”模块和“校准”模块中添加了对“CommonResources”SharedProject的引用。在模块中的RadioButtons的XAML中(例如,AuthorizationModule中的'AuthorizationNavigationItemView'RadioButton'切换到'授权'视图)我写道:

<UserControl x:Class="Authorization.Views.AuthorizationNavigationItemView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:prism="http://prismlibrary.com/"
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
         prism:ViewModelLocator.AutoWireViewModel="True">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/CommonResources;component/Styles/RadiobuttonStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    . . . . . . . . . . . . . .

但是在字符串中

<ResourceDictionary Source="pack://application:,,,/CommonResources;component/Styles/RadiobuttonStyle.xaml"/>

报告错误:此项目中没有对CommonResources程序集的引用。其他RadioButton的XAML也是如此。如何在每个RadioButton的XAML中添加对'CommonResources'ShareProject的引用?

0 个答案:

没有答案