我的silverlight项目中有几个样式名为“Styles.xaml”的文件,如下所示:
但是当我尝试在我的视图上使用它时,我收到此错误消息:
所以我去了“属性”窗口,注意到visual studio没有识别我的样式:
我的风格代码:
<Style x:Key="RemoveDialogButtonStyle" TargetType="Button" BasedOn="{StaticResource BotaoBasicoCsla}">
<Setter Property="Content" Value="Remover" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="17"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Image Source="/Prolex.Net.Protesto;component/Images/Remove.png" HorizontalAlignment="Left" Grid.Column="0" />
<ContentPresenter Content="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="1"/>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
我知道为什么我不能使用StaticResource吗?
答案 0 :(得分:0)
App.xaml中引用了Styles.xaml吗?
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>