Files
Ursa.Avalonia/src/Ursa.Themes.Semi/Controls/EnumSelector.axaml
rabbitism 9d394753d7 feat: 1. Update dependency.
2. Provide sample for Dialog StyleClass option.
2024-11-03 22:26:14 +08:00

37 lines
1.7 KiB
XML

<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:EnumSelector}" TargetType="u:EnumSelector">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Template">
<ControlTemplate TargetType="u:EnumSelector">
<ComboBox
Width="{TemplateBinding Width}"
helpers:ClassHelper.ClassSource="{TemplateBinding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Name="PART_ComboBox"
ItemsSource="{TemplateBinding Values}"
SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedValue, Mode=TwoWay}" />
</ControlTemplate>
</Setter>
<Style Selector="^[DisplayDescription=True] /template/ ComboBox">
<Setter Property="ItemTemplate">
<DataTemplate x:DataType="u:EnumItemTuple">
<TextBlock Text="{Binding DisplayName}" />
</DataTemplate>
</Setter>
</Style>
<Style Selector="^[DisplayDescription=False] /template/ ComboBox">
<Setter Property="ItemTemplate">
<DataTemplate x:DataType="u:EnumItemTuple">
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</Setter>
</Style>
</ControlTheme>
</ResourceDictionary>