Textblock comboitem not displaying when selected
Hi,
I ran into this issue. The following will display both options when combo box is opened, but selecting Option 1 will lead to an invisible selected item.
Regards
I ran into this issue. The following will display both options when combo box is opened, but selecting Option 1 will lead to an invisible selected item.
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ComboBox Foreground="red" Height="36" SelectedIndex="1">
<ComboBoxItem>
<TextBlock Foreground="green">Option 1</TextBlock>
</ComboBoxItem>
<ComboBoxItem Foreground="blue">Option 2</ComboBoxItem>
</ComboBox>
</Grid>
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: Textblock comboitem not displaying when selected
Hi mdube,
This is a known issue that is not yet fixed: #1125.
The workaround could be to move the item visual tree to the ContentTemplate like this:
Would that work for you?
This is a known issue that is not yet fixed: #1125.
The workaround could be to move the item visual tree to the ContentTemplate like this:
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ComboBox Foreground="red" Height="36" SelectedIndex="1">
<ComboBoxItem Content="Option 1">
<ComboBoxItem.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Foreground="green"/>
</DataTemplate>
</ComboBoxItem.ContentTemplate>
</ComboBoxItem>
<ComboBoxItem Foreground="blue">Option 2</ComboBoxItem>
</ComboBox>
</Grid>
Re: Textblock comboitem not displaying when selected
Yes, this is a fine workaround. Thanks.
Who is online
Users browsing this forum: Ahrefs [Bot] and 20 guests