Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
937 views
in Technique[技术] by (71.8m points)

wpf - Error: 'Cannot create unknown type '{clr-namespace:NameSpace.Properties}Settings'.'

I define my settings and styles in a ResourceDictionary:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:properties="clr-namespace:Kavand.UI.Properties">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary>
            <properties:Settings x:Key="settings" />
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="PopupMenu_StackPanel">
        <Setter Property="TextBlock.FontSize" Value="{Binding Source={StaticResource settings}, Path=Default.Font_Menu_Size}" />
        <Setter Property="TextBlock.FontFamily" Value="{Binding Source={StaticResource settings}, Path=Default.Font_Menu_Family}" />
        <Setter Property="TextBlock.FontWeight" Value="{Binding Source={StaticResource settings}, Path=Default.Font_Menu_Weight}" />
        <Style.Resources>
            <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource KavandMenuItem}">
                <Style.Triggers>
                    <Trigger Property="IsChecked" Value="true">
                        <Setter Property="IsEnabled" Value="false" />
                    </Trigger>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsChecked" Value="True" />
                            <Condition Property="IsHighlighted" Value="True" />
                        </MultiTrigger.Conditions>
                        <Setter Property="Foreground" Value="{DynamicResource K_Brush_Gray}" />
                    </MultiTrigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
    </Style>
</ResourceDictionary>

When I run my application, I get the error:

'Cannot create unknown type '{clr-namespace:Kavand.UI.Properties}Settings'.' Line number '6' and line position '14'.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had set the file's "Build Action" property to "Resource". When I changed it to "Page" the problem was resolved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...