fix: fix EnumSelector default Width & Alignment.

This commit is contained in:
Zhang Dian
2024-06-24 16:30:29 +08:00
parent 68c799b032
commit aabc2c9577
2 changed files with 9 additions and 4 deletions

View File

@@ -18,12 +18,16 @@
<Setter Property="Width" Value="{Binding ItemSelfWidth}" /> <Setter Property="Width" Value="{Binding ItemSelfWidth}" />
<Setter Property="Height" Value="{Binding ItemSelfHeight}" /> <Setter Property="Height" Value="{Binding ItemSelfHeight}" />
</Style> </Style>
<Style Selector="u|EnumSelector">
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</UserControl.Styles> </UserControl.Styles>
<DockPanel> <DockPanel>
<u:Form DockPanel.Dock="Left" <u:Form DockPanel.Dock="Left"
LabelAlignment="Left" LabelAlignment="Left"
LabelPosition="Left" LabelPosition="Left"
LabelWidth="*"> LabelWidth="*"
Margin="4 0">
<u:FormGroup> <u:FormGroup>
<u:FormItem Label="Orientation"> <u:FormItem Label="Orientation">
<u:EnumSelector EnumType="Orientation" Value="{Binding SelectedOrientation}" /> <u:EnumSelector EnumType="Orientation" Value="{Binding SelectedOrientation}" />

View File

@@ -4,12 +4,13 @@
xmlns:u="https://irihi.tech/ursa"> xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here --> <!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:EnumSelector}" TargetType="u:EnumSelector"> <ControlTheme x:Key="{x:Type u:EnumSelector}" TargetType="u:EnumSelector">
<Setter Property="Width" Value="100" /> <Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="HorizontalAlignment" Value="Left"></Setter>
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="u:EnumSelector"> <ControlTemplate TargetType="u:EnumSelector">
<ComboBox <ComboBox
Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Bounds.Width}" Width="{TemplateBinding Width}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Name="PART_ComboBox" Name="PART_ComboBox"
ItemsSource="{TemplateBinding Values}" ItemsSource="{TemplateBinding Values}"
SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedValue, Mode=TwoWay}" /> SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedValue, Mode=TwoWay}" />