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>
After looking at your response I realized you are using the xamComboEditor that is WPF only, not the shared control by the same name.
The styles are different and the information I gave you before was for the shared control.
I've been looking at the WPF control and see the behavior you described. I added a style to a dictionary that I then customized in the app but which is basedon the global style.
I then added some textblocks to my sample for purposes of comparison and realized that the customized style is being applied to those textblocks but not to the textblocks that are part of the xamComboEditor style. The xamComboEditor is using the customized textblock style defined in the app.xaml.
I want to look into this further before I submit it to development. You will hear from me shortly either way.
I appreciate your patience while I work thru this question.
<Setter Property="FontSize" Value="12" />
<Style TargetType="igEditor:XamNumericEditor" x:Key="BaseXamNumericEditor">
<Setter Property="FontSize" Value="50"/>
<igEditor:XamNumericEditor Style="{StaticResource BaseXamNumericEditor}" Mask="{}{double:15.5}" Text="12345.67" />
<ControlTemplate x:Key="EditControlTemplate" TargetType="igEditor:XamNumericEditor"> <Border x:Name="OutsideBorder" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <TextBox x:Name="InnerTextBlock" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Text="{TemplateBinding DisplayText}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}"/> </Border> </ControlTemplate>
<igEditor:XamNumericEditor Style="{StaticResource BaseXamNumericEditor}" Mask="{}{double:15.5}" Text="12345.67" EditTemplate={StaticResource EditControlTemplate} />
Attached is a test program to reproduce the issue where the XamEditors are not setting the fontsize correctly for the inner TextBlock
I was wondering if there are any further questions on this topic.
Please let me know if I can be of any further help.
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'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.
Hello Anastas, Can you give us an update on this please?
Thank you.
Yes, we understand why the XamEditor switches font size & your answer essentially restated to what we reported 2 days ago. We expect the XamEditor to maintain the ASSIGNED font size at all time regardless of what the global size is. This is how other wpf controls work where client can override inherrited dependency properties. In this case, the XamEditor picked up the correct size in normal mode but failed in edit mode. We suspect the fix is some where in the EditTemplate.
Please log this as a bug and let us know when it will be fixed. Thanks.