Hi folks,
I've been trying to fine tune the look and feel of a XamDataGrid by applying a gradient to the background and making the default cell background white rather than transparent, but of course, the custom style is ignored if you're using the Theme property to style the XamDataGrid.
I came across this blog entry by Andrew Smith which suggests using a style BasedOn the theme's style which would work nicely.
http://blogs.infragistics.com/blogs/andrew_smith/archive/2009/12/09/common-style-issues-when-using-the-theme-property.aspx
The trick is the BasedOn attribute requires the name/key of the theme style. Where do I find these names?
For example, in the last xaml snippet in the block the style is defined as:
<Style TargetType="igWindows:TabItemEx" BasedOn="{x:Static igThemes:PrimitivesOffice2k7Black.TabItemEx}"> <Setter Property="FontWeight" Value="Bold" /></Style>
How do I know to use "igThemes:PrimitivesOffice2k7Black.TabItemEx"? Where can I get these values?
CheersDavid
Hello jean-Pascal,
Thank you for your post. I have been looking into it and I can say that if you want to set a theme to a WPF control you can set its Theme property. Also if you want to override a particular element’s Properties and use the theme as well you have to follow the steps in the blog from the first post. The BasedOn Property of the Style should be set to the same theme’s element as the Theme Property of the parent control. The Theme property is enum type and have predefined values. I created a sample project for you where I set the Metro theme to the XamTabControl and override the background of the TabItem, by putting the Style for it in the XamTabControl’s Resources. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
I try the following, but does not work.
<Window x:Class="DynamicTabControl.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igWindows="http://infragistics.com/Windows" xmlns:igDp="http://infragistics.com/DataPresenter" xmlns:igThemes="http://infragistics.com/Themes" Title="MainWindow" Height="450" Width="700"> <Grid> <igWindows:XamTabControl Name="xamTabCtrl" ItemsSource="{Binding Collection}" Theme="{x:Static igThemes:DataPresenterMetro.LabelPresenter}"> <igWindows:XamTabControl.ItemContainerStyle> <Style TargetType="{x:Type igWindows:TabItemEx} BasedOn="{igThemes:DataPresenterRoyale.LabelPresenter}"> <Setter Property="Header" Value="{Binding Path=Header}" /> </Style>
What do I wron?
Hi there,
I am having a very similar problem, the difference is I have a customized theme of my own say MyTheme. In one of the grids that I am using I need to override the CellValuePresenter style to do custom coloring. I need this style to be based on my custom theme. The question is how can I make the static style igThemes:DataPresenterMyTheme.CellValuePresenter available in the MyTheme implementation so that I can use it in "BasedOn: in other assemblies.
Thanks much
deyvi
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:CellValuePresenter}"
<!—right here I need something like:
BasedOn="{x:Static igThemes:DataPresenterMyTheme.CellValuePresenter}" -->
>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},
Path=Field.Name}" Value="AField">
<Setter Property="Foreground"
Value="{Binding Path=DataItem.Aproperty, Converter={StaticResource doubleToBrushConverter}}" />
</DataTrigger>
</Style.Triggers>
</Style>
</igDP:XamDataGrid.Resources>
Thanks Alex that's exactly what I needed.
I was able to base a new style on the theme and make the changes I needed.In the XAML for my XamTextEditor I can now specify Theme="Office2k7Black" Style={StaticResource MyTweakedStyle} and get the best of worlds.Much appreciated!
David,
The syntax is as follows:
BasedOn="{x:Static igThemes:GroupingNameThemeName.TargetElement}"
Grouping names can be : Primitives, Editors, DataPresenter.
ThemeNane is the name of the theme - Royale, Onyx,Office2k7Black,etc
TargetElement - name of the element that you want to create the style for
Example:
BasedOn="{x:Static igThemes:DataPresenterRoyale.LabelPresenter}".