feat: MultiComboBox may support placeholder.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<u:MultiComboBox
|
||||
Name="combo"
|
||||
PlaceholderText="Please Select"
|
||||
InnerLeftContent="Left"
|
||||
InnerRightContent="Right"
|
||||
Classes="ClearButton"
|
||||
|
||||
@@ -42,6 +42,18 @@
|
||||
Foreground="{DynamicResource TextBoxInnerForeground}"
|
||||
IsVisible="{TemplateBinding InnerLeftContent,
|
||||
Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<TextBlock
|
||||
x:Name="PlaceholderTextBlock"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsVisible="False"
|
||||
Opacity="0.3"
|
||||
Text="{TemplateBinding PlaceholderText}" />
|
||||
<ScrollViewer
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
@@ -135,6 +147,9 @@
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:selection-empty /template/ TextBlock#PlaceholderTextBlock">
|
||||
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
</Style>
|
||||
|
||||
<!-- Pointerover State -->
|
||||
<Style Selector="^:pointerover">
|
||||
|
||||
@@ -87,7 +87,16 @@ public class MultiComboBox: SelectingItemsControl, IInnerContentControl
|
||||
get => GetValue(SelectedItemTemplateProperty);
|
||||
set => SetValue(SelectedItemTemplateProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public static readonly StyledProperty<string?> PlaceholderTextProperty =
|
||||
ComboBox.PlaceholderTextProperty.AddOwner<MultiComboBox>();
|
||||
|
||||
public string? PlaceholderText
|
||||
{
|
||||
get => GetValue(PlaceholderTextProperty);
|
||||
set => SetValue(PlaceholderTextProperty, value);
|
||||
}
|
||||
|
||||
static MultiComboBox()
|
||||
{
|
||||
FocusableProperty.OverrideDefaultValue<MultiComboBox>(true);
|
||||
|
||||
Reference in New Issue
Block a user