【发布时间】:2012-01-25 03:27:39
【问题描述】:
我在使用 UserControl.Resources 时遇到了一些问题。我一直遇到错误消息“文件 'Resources\Resource.xaml' 不是项目的一部分,或者它的 'Build Action' 属性未设置为 'Resource'。
我在论坛中进行了搜索,但看起来我已经完全按照示例中的说明进行了操作。不知何故,错误仍然存在,并且资源中嵌入的样式未能应用到我的控件中。以下是我的代码:
<UserControl x:Class="Client.NavigationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Client"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalAlignment="Left"
VerticalAlignment="Top"
d:DesignHeight="59"
d:DesignWidth="349"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources\Resource.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Name="grid1"
Width="341"
Height="54"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Button Name="button2"
Width="97"
Height="35"
Margin="106,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Command="{Binding ButtonResponseSection}"
CommandParameter="ResponseSection"
Content="ResponseSection"
Style="{DynamicResource GlassButton}" />
</Grid>
</UserControl>
请帮忙:-(..
【问题讨论】:
-
抱歉,我不太明白您关于“您的项目文件看起来像”的问题吗? ..
标签: wpf xaml user-controls