【发布时间】:2022-12-01 20:32:12
【问题描述】:
Using Visual Studio 2022, .NET Core6, WPF (with MVVM), Mahapps Metro (+IconPacks), C#
I'm using Mahapps Metro and I defined a style for the ComboBox so that it shows a clear text button.
<Style TargetType="ComboBox" x:Key="{x:Type ComboBox}"
BasedOn="{StaticResource MahApps.Styles.ComboBox}">
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="9"/>
<Setter Property="mah:TextBoxHelper.ClearTextButton" Value="True"/>
</Style>
This seems to work perfectly...
However... When I also define a style for TextBlock then the X icon is suddenly shown as the letter 'r'
<Style x:Key="{x:Type TextBlock}" TargetType="TextBlock"
BasedOn="{StaticResource MahApps.Styles.TextBlock}">
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="9"/>
</Style>
The xaml for my combobox is quite simple...
<ComboBox x:Name="CustomerCustomerCategoryComboBox"
Grid.Column="2" Grid.Row="2"
MinWidth="100"
Grid.ColumnSpan="3"
I'm completely baffled to be honest. I have no clue whatsoever as to what causes this behaviour. Has someone else experienced this or, better even, know what I can do to solve this ?
I've tried all sorts of things... removing the Texblock style solves it obviously but that way I lose the style for all my other textblocks. Tried playing around with the Style settings, googled my problem with several keywords and phrases but I seem to be the only one???
【问题讨论】:
-
the combobox probaly uses a textbox inside that is now restyled. Probably previously it was using a custom font to show the X and you set it to Segoe UI, you probaly need to add a resource to the combobox of hte orignally used textboxstyle to prevent that
标签: c# wpf visual-studio-2022 mahapps.metro