1.I have written to application-level TextBlock style in App.xaml.like this.<Application x:Class="XamDateTimeEditorSample.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml"> <Application.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="Red" /> <Setter Property="FontFamily" Value="Arial" /> <Setter Property="FontSize" Value="10" /> </Style> </Application.Resources></Application>
2.I was placed XamDateTimeEditor control on window.(In the hope that it overrides the style has been described ...)<Window x:Class="XamDataGridWork.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igEditors="http://infragistics.com/Editors" Title="Window1" Height="100" Width="300" > <Grid x:Name="LayoutRoot"> <igEditors:XamDateTimeEditor Name="xamDateTimeEditor1" VerticalAlignment="Top"> <igEditors:XamDateTimeEditor.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontSize" Value="30"/> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="Foreground" Value="Blue" /> </Style> </igEditors:XamDateTimeEditor.Resources> </igEditors:XamDateTimeEditor> </Grid></Window>
I build and run this project.but TextBlock style could not be overridden...I found a case similar in the forums.[Odd problem with inheriting styles]http://community.infragistics.com/forums/p/19098/74050.aspx#74050I'm still looking for a solution to this problem. but still not resolved.help please
Sincerely,Yung Emary
You may want to try contacting Microsoft's support since this isn't something that we have any control over. The same exact behavior can be seen if you use a ListBox. e.g.
I'm guessing that since the elements that ultimately contain the textblock (listboxitem in the case above) are not in the logical tree that they do not pick up that local style but again you would need to contact MS to find out for sure what the actual reason is and what workaround might be possible.
Mr.Andrew, thank you for reply.My explanation was insufficient.....When Application TextBlock Style written in the project, (ex. FontSize="6")and placed the screen XamDateTimeEditor on Window.Then small font shown at EditArea and DropDownCalender.XamDateTimeEditor control I tried to change the FontSize property.(FontSize="24")Although property values have changed, the size of the characters still look small....the style scenarios aside,In this situation,How I should set the style of XamDateTimeEditor?I seek a good solution and sample.I need your good ideas.regards.
I understood what you described and my point is still applicable. It seems that when WPF creates a textblock for an element that is not within the logical tree and there is a application level style for that element then that style will be used. Since that style is setting the FontSize that property is used instead of the inherited value set on an ancestor element in the visual tree. Again, this is not something that we have any control over and the same thing happens with a ListBox. e.g.
Again I would recommend that you contact MS' support or that you not use an application style that targets TextBlock. Since those 3 properties are inherited properties maybe you should just set those on the window.
Mr.Andrew
I was convinced by your explanation.I'll review style-scenario again.many thanks.Yung.Emary