ComboBox selected item template #1023
-
Hi 👋 There is a way to set the item template for the selected item of Fluent ComboBox, like with the default ComboBox? I have the following code that produce the attached results: <ComboBox ItemsSource="{Binding Materials}"
SelectedItem="{Binding Material}"
ItemTemplate="{StaticResource materialCombo}"/>
<fluent:ComboBox Header="Material"
ItemsSource="{Binding Materials}"
SelectedItem="{Binding Material}"
Icon="{Binding Material,Converter={StaticResource MaterialToIconConverter}}"
ItemTemplate="{StaticResource materialCombo}"
InputWidth="100"/>
The DataTemplate is declared in Resources: <DataTemplate x:Key="materialCombo">
<StackPanel Orientation="Horizontal">
<Image Width="14" Height="14" Stretch="UniformToFill" Margin="0,0,5,0">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding Level}" Value="Warning">
<Setter Property="Source" Value="{StaticResource Icon.Logger.Warning}"/>
<Setter Property="ToolTip" Value="{DynamicResource Lang.Warning}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<TextBlock Text="{Binding Name}"></TextBlock>
</StackPanel>
</DataTemplate>
Thank you, I really appreciate this project. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi there. |
Beta Was this translation helpful? Give feedback.
Hi there.
You have to set
IsEditable
to false on the ComboBox.Contrary to the default value of false in a regular WPF ComboBox the original authors of this project chose true as the default value and i never had the balls to change that.
But as this quite often confuses users i might have to change it in future version.