mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-05-02 05:51:28 +08:00
Merge pull request #655 from irihitech/12.0/ComboBox
Implement IsEditable for ComboBox
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<vm:ComboBoxDemoViewModel />
|
<vm:ComboBoxDemoViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
<ScrollViewer>
|
||||||
<StackPanel Spacing="20">
|
<StackPanel Spacing="20">
|
||||||
<StackPanel.Styles>
|
<StackPanel.Styles>
|
||||||
<Style Selector="ComboBox">
|
<Style Selector="ComboBox">
|
||||||
@@ -48,5 +49,8 @@
|
|||||||
<ComboBox Width="100" Classes="Bordered" PlaceholderText="Bordered" />
|
<ComboBox Width="100" Classes="Bordered" PlaceholderText="Bordered" />
|
||||||
<ComboBox Width="100" Classes="Bordered" IsEnabled="False" />
|
<ComboBox Width="100" Classes="Bordered" IsEnabled="False" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<ToggleSwitch Name="toggle" IsChecked="True" Content="IsEditable" />
|
||||||
|
<ComboBox IsEditable="{Binding #toggle.IsChecked}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -67,8 +67,14 @@
|
|||||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
TextTrimming="CharacterEllipsis"
|
TextTrimming="CharacterEllipsis"
|
||||||
Foreground="{TemplateBinding PlaceholderForeground}"
|
Foreground="{TemplateBinding PlaceholderForeground}"
|
||||||
IsVisible="{TemplateBinding SelectionBoxItem,Converter={x:Static ObjectConverters.IsNull}}"
|
Text="{TemplateBinding PlaceholderText}">
|
||||||
Text="{TemplateBinding PlaceholderText}" />
|
<TextBlock.IsVisible>
|
||||||
|
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||||
|
<TemplateBinding Property="SelectionBoxItem" Converter="{x:Static ObjectConverters.IsNull}" />
|
||||||
|
<TemplateBinding Property="IsEditable" Converter="{x:Static BoolConverters.Not}" />
|
||||||
|
</MultiBinding>
|
||||||
|
</TextBlock.IsVisible>
|
||||||
|
</TextBlock>
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Name="ContentPresenter"
|
Name="ContentPresenter"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
@@ -76,7 +82,20 @@
|
|||||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
Content="{TemplateBinding SelectionBoxItem}"
|
Content="{TemplateBinding SelectionBoxItem}"
|
||||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" />
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||||
|
IsVisible="{TemplateBinding IsEditable, Converter={x:Static BoolConverters.Not}}" />
|
||||||
|
<TextBox
|
||||||
|
Name="PART_EditableTextBox"
|
||||||
|
Grid.Column="0"
|
||||||
|
Theme="{StaticResource LooklessTextBox}"
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Foreground="{TemplateBinding Foreground}"
|
||||||
|
Text="{TemplateBinding Text, Mode=TwoWay}"
|
||||||
|
Watermark="{TemplateBinding PlaceholderText}"
|
||||||
|
IsVisible="{TemplateBinding IsEditable}" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
Name="ClearButton"
|
Name="ClearButton"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
@@ -212,6 +231,11 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[IsEditable=true]">
|
||||||
|
<Setter Property="IsTabStop" Value="False" />
|
||||||
|
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^.Bordered">
|
<Style Selector="^.Bordered">
|
||||||
<Style Selector="^ /template/ Border#Background">
|
<Style Selector="^ /template/ Border#Background">
|
||||||
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBorderedBackground}" />
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBorderedBackground}" />
|
||||||
|
|||||||
@@ -488,6 +488,7 @@
|
|||||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
<Setter Property="FocusAdorner" Value="{x:Null}" />
|
<Setter Property="FocusAdorner" Value="{x:Null}" />
|
||||||
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
|
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
|
||||||
|
<Setter Property="ContextFlyout" Value="{StaticResource DefaultTextBoxContextFlyout}" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="TextBox">
|
<ControlTemplate TargetType="TextBox">
|
||||||
<Border Name="PART_ContentPresenterBorder" MinHeight="{TemplateBinding MinHeight}">
|
<Border Name="PART_ContentPresenterBorder" MinHeight="{TemplateBinding MinHeight}">
|
||||||
|
|||||||
Reference in New Issue
Block a user