JuHwon
JuHwon

Reputation: 2063

wpf Resource template not applied

I got a ResourceDictionary CustomStyles.xaml and i've implemented it in two views. In the first view all templates and styles are working just fine. Though in the second view my Templates aren't applied to my DataGrid and when i enter the view the following output is shown. Still in my VS2012 Designer the HeaderTemplates are shown correct.

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'

these Resources are not mine and i've not applied them in my view. My implemented Resources:

<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>

and finally my 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. one header- and cell-template

<DataTemplate x:Key="InputGridIndexHeaderTempalte">
    <TextBlock Text="#" />
</DataTemplate>

<DataTemplate x:Key="InputGridIndexCellTempalte">
    <TextBlock Text="{Binding Index}" />
</DataTemplate>

screenshot of my designer enter image description here

and here how it looks at the application: enter image description here

please help!!! and ask if you need more information!

Upvotes: 1

Views: 2255

Answers (1)

JuHwon
JuHwon

Reputation: 2063

I didnt had my xaml ResourceDictionary in my App.xaml. I dont know why... though if i place it there it all works fine.

Upvotes: 2

Related Questions