Hi all,
I'm having trouble with something that I'm sure should be simple... not sure if there is a problem or if I'm going mad! I have defined a style for a DataRecordCellArea (just sets the BackgroundHover property), within the resources of a XamDataGrid (defined in Xaml). This works fine. The problem arises when moving the same style into a separate ResourceDictionary file. I have changed the Resources of the XamDataGrid to the following:
<ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
...and moved the style within test.xaml. However, the style is ignored in this case; it only works when placed directly in the resources section of the XamDataGrid itself.
I tried the same test simply using a button and having a style change its background – in this case it works when the style is placed directly within the buttons resources, or within a separate resource dictionary... am I missing something?
Cheers,
Dave
Hi,
Can someone confirm, should I be able to define styles in a separate XAML resource dictionary file?
Like so...
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igDP="clr-namespace:Infragistics.Windows.DataPresenter;assembly=Infragistics3.Wpf.DataPresenter.v8.2">
<Style TargetType="Button">
<Setter Property="Background"
Value="Pink" />
</Style>
<Style TargetType="{x:Type igDP:DataRecordCellArea}">
<Setter Property="BackgroundHover">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FF2225FF"
Offset="0" />
<GradientStop Color="#FFB9D8FF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderHoverBrush"
Value="#FF000000" />
</ResourceDictionary>
In the above case, the button style applies, but not the DataRecordCellArea style.
What's probably happening is that you have the Theme property set so the Theme resources are being added to the MergedDictionaries after your dictionary. I would recommend reporting this to the support group. For now what you could do is to set the Source of the ResourceDictionary you are putting in the grid's Resources instead of on a RD within the MergedDictionaries.
i.e. put the following as the Resources
<ResourceDictionary Source="/Daves Tests;component/Themes/test.xaml" />
Hi Andrew,
Thanks very much, I wondered why it was not working... that makes sense now. Your workaround worked great.
I'll report it to support now,
Where exactly is this resourcedictionary placed inside the xamdatagrid xaml structure?