I have a global textblock style set at the app level so all textblocks will inherit the style (unless overridden).
I also have a style for the xamDataGrid header row for background etc. When I set the foreground, font size, etc it is not taking but is taking the app level textblock style. How can I stop infragistics wpf controls from doing this? Having same issue now with xamMaskedEditor.
Hope that makes since.
<StackPanel> <StackPanel.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontSize" Value="22" /> <Setter Property="Foreground" Value="Red" /> </Style> </StackPanel.Resources> <igEditors:XamMaskedEditor Text="37128" Mask="nnnnn"> <igEditors:XamMaskedEditor.Style> <Style TargetType="{x:Type igEditors:XamMaskedEditor}"> <Setter Property="Foreground" Value="Blue" /> </Style> </igEditors:XamMaskedEditor.Style> </igEditors:XamMaskedEditor> <TextBlock Text="This is a test" /> <TextBlock Text="This is a test overiding inherited style"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="Blue" /> </Style> </TextBlock.Style> </TextBlock> </StackPanel>
Hello,
To change the style of the header area you have to create a style and set the TargetType property to {x:Type igDP:LabelPresenter} and modify it like you wish. In this case you can see the default style of the LabelPresenter in the local directory "~\Infragistics\NetAdvantage for WPF 2008 Vol. 2\DefaultStyles" and all the wpf controls too. In the future it would be easier to create styles for the particular area and not worry about which style overrides the other.
Hope this helps.
I do have a style for LabelPresenter which will chagne the header row background, etc, but not the FontSize or Foreground, it keeps taking the TextBlock style from the app level.
I attached a zip of the test project I am using.
Here is the xaml from the App.xaml:
<Application x:Class="XamDataGridWork.App" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml StartupUri="Window1.xaml">
<Application.Resources>
</Application.Resources></Application>
Here is the xaml for the Window1.xaml (the only other xaml page):
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:igDP=http://infragistics.com/DataPresenter x:Class="XamDataGridWork.Window1" Title="Window1" Height="768" Width="1024">
<Window.Resources>
<!-- XamDataGrid - Header Style --><Style TargetType="{x:Type igDP:LabelPresenter}" BasedOn="{x:Null}"><Setter Property="Background" Value="Gray" /><Setter Property="InnerBorderBrush" Value="#00000000" /><Setter Property="OuterBorderBrush" Value="#00000000" /><Setter Property="LabelHighlight" Value="Green" /><Setter Property="Foreground" Value="Blue" /><Setter Property="FontSize" Value="30" /><Setter Property="FontWeight" Value="Bold" /></Style>
<XmlDataProvider x:Key="BookData" XPath="/Books"><x:XData><Books xmlns=""><Book ISBN="0-7356-0562-9" Stock="in"><Title>XML in Action</Title><Summary>XML Web Technology</Summary></Book>
</Window.Resources>
<Grid>
<igDP:XamDataGrid x:Name="XamDataGrid1" DataSource="{Binding Source={StaticResource BookData},XPath=Book}" />
</Window>