我有一个ResourceDictionary CustomStyles.xaml
,我已经在两个视图中实现了它。
在第一个视图中,所有模板和样式都正常工作。虽然在第二个视图中我的模板不适用于我的DataGrid
,但当我进入视图时,会显示以下输出。仍然在我的VS2012设计器中,HeaderTemplates
显示正确。
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='GrayBrush7'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='Gray3'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='Gray3'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='ControlBackgroundBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TextBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='GrayBrush7'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TextBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='GrayBrush7'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='Gray3'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='Gray3'
这些资源不是我的,我没有在我看来应用它们。 我实现了资源:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml" />
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml" />
<ResourceDictionary Source="/Fluent;Component/Themes/Metro/White.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="/PQS;component/Resources/CustomStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
最后我的Datatemplate:
<DataGrid ItemsSource="{Binding Items.View}" Style="{DynamicResource InputDataGridStyle}" Grid.Row="1" Name="InputGrid" Loaded="InputGrid_Loaded" KeyUp="InputGrid_OnKeyUp">
<DataGrid.Columns>
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridIndexHeaderTempalte}" CellTemplate="{DynamicResource InputGridIndexCellTempalte}" />
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridTimeStampHeaderTemplate}" CellTemplate="{DynamicResource InputGridTimeStampCellTemplate}" />
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridUserHeaderTemplate}" CellTemplate="{DynamicResource InputGridUserCellTemplate}" />
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridValueHeaderTemplate}" CellTemplate="{DynamicResource InputGridValueCellTempalte}" Visibility="{Binding ElementName=InputGrid, Path=DataContext.CharacteristicMeasure.Characteristic.CharacteristicType.IsBool,Converter={StaticResource boolToInv}, ConverterParameter=true}" />
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridValueHeaderTemplate}" CellTemplate="{DynamicResource InputGridBoolValueCellTempalte}" Visibility="{Binding ElementName=InputGrid, Path=DataContext.CharacteristicMeasure.Characteristic.CharacteristicType.IsBool,Converter={StaticResource boolToInv}}" />
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridValidHeaderTemplate}" CellTemplate="{DynamicResource InputGridValidCellTemplate}" />
<DataGridTemplateColumn HeaderTemplate="{DynamicResource InputGridTextHeaderTemplate}" CellTemplate="{DynamicResource InputGridTextCellTemplate}" />
</DataGrid.Columns>
</DataGrid>
e.g。一个标题和单元格模板
<DataTemplate x:Key="InputGridIndexHeaderTempalte">
<TextBlock Text="#" />
</DataTemplate>
<DataTemplate x:Key="InputGridIndexCellTempalte">
<TextBlock Text="{Binding Index}" />
</DataTemplate>
我的设计师的截图
以及它如何看待应用程序:
请帮忙!!!并询问您是否需要更多信息!
答案 0 :(得分:2)
我的ResourceDictionary
中没有我的xaml App.xaml
。我不知道为什么......但如果我把它放在那里它一切正常。