Merge pull request #357 from gehongyan/multicombobox-placeholder
feat: MultiComboBox may support placeholder (watermark)
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<u:MultiComboBox
|
<u:MultiComboBox
|
||||||
Name="combo"
|
Name="combo"
|
||||||
|
Watermark="Please Select"
|
||||||
InnerLeftContent="Left"
|
InnerLeftContent="Left"
|
||||||
InnerRightContent="Right"
|
InnerRightContent="Right"
|
||||||
Classes="ClearButton"
|
Classes="ClearButton"
|
||||||
|
|||||||
@@ -42,6 +42,18 @@
|
|||||||
Foreground="{DynamicResource TextBoxInnerForeground}"
|
Foreground="{DynamicResource TextBoxInnerForeground}"
|
||||||
IsVisible="{TemplateBinding InnerLeftContent,
|
IsVisible="{TemplateBinding InnerLeftContent,
|
||||||
Converter={x:Static ObjectConverters.IsNotNull}}" />
|
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 Watermark}" />
|
||||||
<ScrollViewer
|
<ScrollViewer
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
@@ -135,6 +147,9 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</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 -->
|
<!-- Pointerover State -->
|
||||||
<Style Selector="^:pointerover">
|
<Style Selector="^:pointerover">
|
||||||
|
|||||||
@@ -87,7 +87,16 @@ public class MultiComboBox: SelectingItemsControl, IInnerContentControl
|
|||||||
get => GetValue(SelectedItemTemplateProperty);
|
get => GetValue(SelectedItemTemplateProperty);
|
||||||
set => SetValue(SelectedItemTemplateProperty, value);
|
set => SetValue(SelectedItemTemplateProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<string?> WatermarkProperty =
|
||||||
|
TextBox.WatermarkProperty.AddOwner<MultiComboBox>();
|
||||||
|
|
||||||
|
public string? Watermark
|
||||||
|
{
|
||||||
|
get => GetValue(WatermarkProperty);
|
||||||
|
set => SetValue(WatermarkProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
static MultiComboBox()
|
static MultiComboBox()
|
||||||
{
|
{
|
||||||
FocusableProperty.OverrideDefaultValue<MultiComboBox>(true);
|
FocusableProperty.OverrideDefaultValue<MultiComboBox>(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user