My company uses some global styles for xam controls. I need to override some of those styles for a specific instance of a xamcomboeditor.
In the style below I set the background to yellow and the font size to 50. The background is set correctly but the fontsize is not. Why is that? I suspect I need to create a style for a type other than xamcomboeditor. I want to hard code the fontsize at the control level so no other style overrides it. How do I do that?
<igEditors:XamComboEditor
x:Name="transferTypeCombo"
Style="{StaticResource BaseXamComboEditor}"
ValuePath="Tag"
Width="120"
Value="{Binding NATIVE_TRANSFER_TYPE}">
<igEditors:XamComboEditor.ItemsProvider>
<igEditors:ComboBoxItemsProvider>
<igEditors:ComboBoxItemsProvider.Items>
<igEditors:ComboBoxDataItem DisplayText="PM Transfer" Value="0"></igEditors:ComboBoxDataItem>
<igEditors:ComboBoxDataItem DisplayText="Auction" Value="1"></igEditors:ComboBoxDataItem>
</igEditors:ComboBoxItemsProvider.Items>
</igEditors:ComboBoxItemsProvider>
</igEditors:XamComboEditor.ItemsProvider>
</igEditors:XamComboEditor>
Hi,
You may need to use a based on reference so that you can use your company’s style but you can target the SpecializedTextBox and TextBlock in the XamComboEditor style by adding the following to the resources of your XamComboEditor. This will take care of the text area of the xamComboEditor.
<Style TargetType="igPrim:SpecializedTextBox" >
<Setter Property="FontSize" Value="20"/>
</Style>
<Style TargetType="TextBlock">
<Style TargetType="ig:XamComboEditor" >
You might want to look at these links concerning applying styles
http://es.infragistics.com/community/blogs/andrew_smith/archive/2009/12/09/common-style-issues-when-using-the-theme-property.aspx
http://es.infragistics.com/community/blogs/marketing/archive/2013/03/05/styles-in-wpf.aspx
Please let me know if you also need to customize the text in the dropdown.
Edit: Marianne, thank you for your reply. I was on a mad dash out of the office last night and i wanted post this before I left. Sorry for that, here is more info about the issue:
I tried the styles you suggested and they do not work so I started pulling my app apart. My company has some common styles we all use and included in those style is a global textblock style as shown below. It appears this style is preventing other more locally defined styles from being applied to the xamcomboeditor. As you can see in the xaml below, the style defined in the resources of the xamcomboeditor is not applied when the global textblock style is also used.
My new question is: If my app contains a global (unkeyed) TextBlock style, how do I style the font size for XamComboEditor?
I found the problem to be this global TextBlock style:
<Setter Property="FontFamily" Value="Calibri"/>
<Setter Property="FontSize" Value="12"/>
This was unexpected because I suspected a global textblock style was a problem early on so I implemented the suggestion found here to work around it:
http://stackoverflow.com/questions/1303634/how-to-override-a-global-style-that-doesnt-have-an-xkey-or-alternatively-ap
The solution suggestion suggested in the link above should work but for some reason it does not. The only fix I can think of at the moment is to give the TextBlock style a key. Hope this saves someone else from having to go through this.
Following does not work:
Width="120" Height="30" >
<igEditors:XamComboEditor.Resources>
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="FontSize" Value="50" />
</igEditors:XamComboEditor.Resources>
Hello...is any one looking into this bug?
Hello,
The reason why inner textBlock change its fontSize is because of the first Style. It doesn't have set a key, so it applies for all TextBlock in the application. If you remove this style(it's placed at your App.xaml) or set it a key, then xamEditor should work as expected.
Regards,
Anastas
Hello Anastas, Can you give us an update on this please?
Thank you.
I've logged this behavior as a development issue after consulting with our development staff. I will be opening a case for each of you and linking your cases to the development issue so that you will be notified directly of progress with this issue.
I appreciate your patience while I worked thru my investigation.
Hi All,
I have already given Jake the response from our developers thru the case I created for him but I'm sure others on this thread are looking for the same information so I'll add their explanation here.
Their explanation assumes that you have a style defined in your resources, something like this one.
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="18"/>
And have then added styles for the other editors, including the XamComboEditor, setting font sizes.
This is not a bug. This behavior is the result of the way the .NET framework works with regards to how it gives precedence to style setters over inherited value of an inherited property (FontSize is inherited). So if a control uses TextBlock in its hierarchy of elements to display content, that textblock will end up using the font size specified on the TextBlock style. Any FontSize specified on the control itself will not be used by any TextBlocks that are inside the control. This behavior is observed by the following usage of ComboBox in this sample:
<ComboBox SelectedIndex="0" FontSize="40" >
<ComboBox.Items>
<sys:String>A</sys:String>
<sys:String>B</sys:String>
</ComboBox.Items>
</ComboBox>
If you use above combobox in a sample, it will not display 40 font size. It will display 18 font size as set on the TextBlock. Furthermore if you set the IsEditable to true on the above ComboBox, you'll notice a different behavior in that it's edit portion will be 40 font size but the drop-down will be 18 font size. Basically controls typically don't have any logic to explicitly template-bind textblock's font related properties to the control's properties because they are inherited. If you however created TextBlock styles, then these kinds of issues will popup in a lot of different controls, (not only our controls but .NET framework's controls).
I hope this helps explain the behavior you are seeing. Please let me know if you have any questions.
I was wondering if there are any further questions on this topic.
Please let me know if I can be of any further help.