Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1336
Putting Styles in a MergedDictionary?
posted

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> 

 

<ResourceDictionary Source="/Daves Tests;component/Themes/test.xaml" /> 

 

</ResourceDictionary.MergedDictionaries>

 

</ResourceDictionary>

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

Parents
  • 1336
    posted

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

    </Style>

    </ResourceDictionary>

    In the above case, the button style applies, but not the DataRecordCellArea style.

    Regards,Dave
Reply Children