feat: add avalonia basic ComboBox style.
This commit is contained in:
1 parent
d4406c2888
commit
94ee336714
12 files changed
+593
-8
No files matched your search
@@ -15,7 +15,7 @@
|
|||||||
[ "TextBlock", "TextBlockDemo", "Brush.TextBlock", "", "" ],
|
[ "TextBlock", "TextBlockDemo", "Brush.TextBlock", "", "" ],
|
||||||
[ "NumericUpDown", "NumericUpDownDemo", "Brush.NumericListBox", "", "" ],
|
[ "NumericUpDown", "NumericUpDownDemo", "Brush.NumericListBox", "", "" ],
|
||||||
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
|
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
|
||||||
[ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ],
|
[ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "" ],
|
||||||
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
|
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
|
||||||
[ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ],
|
[ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ],
|
||||||
[ "Calendar", "CalendarDemo", "Brush.Calendar", "", "" ],
|
[ "Calendar", "CalendarDemo", "Brush.Calendar", "", "" ],
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:vm="clr-namespace:HandyControlDemo.ViewModel"
|
||||||
|
x:Class="HandyControlDemo.UserControl.ComboBoxDemo"
|
||||||
|
DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}">
|
||||||
|
<ScrollViewer>
|
||||||
|
<hc:UniformSpacingPanel Spacing="32"
|
||||||
|
Margin="32"
|
||||||
|
ChildWrapping="Wrap">
|
||||||
|
<StackPanel>
|
||||||
|
<ComboBox ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox ItemsSource="{Binding DataList}"
|
||||||
|
Margin="0,16,0,0"
|
||||||
|
IsEnabled="False" />
|
||||||
|
|
||||||
|
<ComboBox hc:TitleElement.Title="This is the title"
|
||||||
|
Theme="{StaticResource ComboBoxExtend}"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox hc:TitleElement.Title="This is the title"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
Theme="{StaticResource ComboBoxExtend}"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox hc:TitleElement.Title="This is the title"
|
||||||
|
Theme="{StaticResource ComboBoxExtend}"
|
||||||
|
Margin="0,16,0,0"
|
||||||
|
ItemsSource="{Binding DataList}"
|
||||||
|
IsEnabled="False" />
|
||||||
|
<ComboBox PlaceholderText="Please enter content"
|
||||||
|
ItemsSource="{Binding DataList}"
|
||||||
|
hc:TitleElement.Title="This item must be filled in"
|
||||||
|
Theme="{StaticResource ComboBoxExtend}"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
Margin="0,16,0,0" />
|
||||||
|
<ComboBox Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Theme="{StaticResource ComboBoxExtend}"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox Width="380"
|
||||||
|
ItemsSource="{Binding DataList}"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
PlaceholderText="Please enter content"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
Theme="{StaticResource ComboBoxExtend}"
|
||||||
|
Margin="0,16,0,0" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
<ComboBox ItemsSource="{Binding DataList}"
|
||||||
|
Theme="{StaticResource ComboBox.Small}" />
|
||||||
|
<ComboBox ItemsSource="{Binding DataList}"
|
||||||
|
Margin="0,16,0,0"
|
||||||
|
IsEnabled="False"
|
||||||
|
Theme="{StaticResource ComboBox.Small}" />
|
||||||
|
|
||||||
|
<ComboBox hc:TitleElement.Title="This is the title"
|
||||||
|
Theme="{StaticResource ComboBoxExtend.Small}"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox hc:TitleElement.Title="This is the title"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
Theme="{StaticResource ComboBoxExtend.Small}"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox hc:TitleElement.Title="This is the title"
|
||||||
|
Theme="{StaticResource ComboBoxExtend.Small}"
|
||||||
|
Margin="0,16,0,0"
|
||||||
|
ItemsSource="{Binding DataList}"
|
||||||
|
IsEnabled="False" />
|
||||||
|
<ComboBox PlaceholderText="Please enter content"
|
||||||
|
ItemsSource="{Binding DataList}"
|
||||||
|
hc:TitleElement.Title="This item must be filled in"
|
||||||
|
Theme="{StaticResource ComboBoxExtend.Small}"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
Margin="0,16,0,0" />
|
||||||
|
<ComboBox Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Theme="{StaticResource ComboBoxExtend.Small}"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
ItemsSource="{Binding DataList}" />
|
||||||
|
<ComboBox Width="380"
|
||||||
|
ItemsSource="{Binding DataList}"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
PlaceholderText="Please enter content"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
Theme="{StaticResource ComboBoxExtend.Small}"
|
||||||
|
Margin="0,16,0,0" />
|
||||||
|
</StackPanel>
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace HandyControlDemo.UserControl;
|
||||||
|
|
||||||
|
public partial class ComboBoxDemo : Avalonia.Controls.UserControl
|
||||||
|
{
|
||||||
|
public ComboBoxDemo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Globalization;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using HandyControlDemo.Properties.Langs;
|
||||||
|
using HandyControlDemo.Tools.Converter;
|
||||||
|
|
||||||
namespace HandyControlDemo.ViewModel;
|
namespace HandyControlDemo.ViewModel;
|
||||||
|
|
||||||
@@ -20,4 +24,23 @@ public partial class InputElementDemoViewModel : ObservableValidator
|
|||||||
[ObservableProperty] private double? _doubleValue1;
|
[ObservableProperty] private double? _doubleValue1;
|
||||||
|
|
||||||
[ObservableProperty] private double? _doubleValue2;
|
[ObservableProperty] private double? _doubleValue2;
|
||||||
|
|
||||||
|
[ObservableProperty] private IList<string>? _dataList;
|
||||||
|
|
||||||
|
public InputElementDemoViewModel()
|
||||||
|
{
|
||||||
|
DataList = GetComboBoxDemoDataList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<string> GetComboBoxDemoDataList()
|
||||||
|
{
|
||||||
|
var converter = new StringRepeatConverter();
|
||||||
|
var list = new List<string>();
|
||||||
|
for (int i = 1; i <= 9; i++)
|
||||||
|
{
|
||||||
|
list.Add($"{converter.Convert(Lang.Text, null!, i, CultureInfo.CurrentCulture)}{i}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,444 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=System.Runtime">
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBoxItemBaseStyle"
|
||||||
|
TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="{StaticResource DefaultControlPadding}" />
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="Transparent" />
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="0" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="CornerRadius"
|
||||||
|
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<ContentPresenter Name="PART_ContentPresenter"
|
||||||
|
Foreground="{TemplateBinding Foreground}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Padding="{TemplateBinding Padding}" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^:pointerover /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource SecondaryRegionBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:selected /template/ ContentPresenter">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource TextIconBrush}" />
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBoxBaseStyle"
|
||||||
|
TargetType="ComboBox">
|
||||||
|
<Setter Property="ItemContainerTheme"
|
||||||
|
Value="{StaticResource ComboBoxItemBaseStyle}" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheLeft"
|
||||||
|
Value="0,7,6,0" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheTop"
|
||||||
|
Value="8,0,0,5" />
|
||||||
|
<Setter Property="hc:TitleElement.HorizontalAlignment"
|
||||||
|
Value="Left" />
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="{StaticResource DefaultCornerRadius}" />
|
||||||
|
<Setter Property="CornerRadius"
|
||||||
|
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="{StaticResource DefaultInputPadding}" />
|
||||||
|
<Setter Property="VerticalContentAlignment"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="HorizontalContentAlignment"
|
||||||
|
Value="Left" />
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource BorderBrush}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="1" />
|
||||||
|
<Setter Property="FocusAdorner"
|
||||||
|
Value="{x:Null}" />
|
||||||
|
<Setter Property="MaxDropDownHeight"
|
||||||
|
Value="504" />
|
||||||
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
|
||||||
|
Value="Disabled" />
|
||||||
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility"
|
||||||
|
Value="Auto" />
|
||||||
|
<Setter Property="PlaceholderForeground"
|
||||||
|
Value="{DynamicResource ThirdlyTextBrush}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<DataValidationErrors>
|
||||||
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}" />
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding PlaceholderText}" />
|
||||||
|
<ContentControl x:Name="ContentPresenter"
|
||||||
|
Content="{TemplateBinding SelectionBoxItem}"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||||
|
<Path Grid.Column="1"
|
||||||
|
IsVisible="{TemplateBinding IsDropDownOpen, Converter={x:Static BoolConverters.Not}}"
|
||||||
|
Data="{StaticResource DownGeometry}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="14"
|
||||||
|
Stretch="Uniform"
|
||||||
|
Fill="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Margin="{TemplateBinding Padding, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}" />
|
||||||
|
<Path Grid.Column="1"
|
||||||
|
IsVisible="{TemplateBinding IsDropDownOpen}"
|
||||||
|
Data="{StaticResource UpGeometry}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="14"
|
||||||
|
Stretch="Uniform"
|
||||||
|
Fill="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Margin="{TemplateBinding Padding, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}" />
|
||||||
|
<Popup Grid.Column="0"
|
||||||
|
Name="PART_Popup"
|
||||||
|
WindowManagerAddShadowHint="False"
|
||||||
|
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
|
||||||
|
PlacementTarget="border"
|
||||||
|
IsLightDismissEnabled="True"
|
||||||
|
InheritsTransform="True">
|
||||||
|
<Border x:Name="PopupBorder"
|
||||||
|
Background="{DynamicResource RegionBrush}"
|
||||||
|
BorderBrush="{DynamicResource BorderBrush}"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
Margin="8,0,8,8"
|
||||||
|
Effect="{StaticResource EffectShadow2}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}">
|
||||||
|
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||||
|
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||||
|
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||||
|
Margin="2">
|
||||||
|
<ItemsPresenter Name="PART_ItemsPresenter"
|
||||||
|
ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
</DataValidationErrors>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^:disabled">
|
||||||
|
<Setter Property="Opacity"
|
||||||
|
Value="0.4" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:pointerover /template/ Border#border">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource SecondaryBorderBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Style Selector="^:pointerover /template/ Border#border">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:dropdownopen">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:error /template/ Border#border">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource DangerBrush}" />
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTemplate x:Key="ComboBoxExtendTopTemplate"
|
||||||
|
TargetType="ComboBox">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition MinHeight="{Binding Path=(hc:InfoElement.MinContentHeight), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
Height="{Binding Path=(hc:InfoElement.ContentHeight), RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Double2GridLengthConverter}}" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<DockPanel LastChildFill="True"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
IsVisible="{Binding Path=(hc:TitleElement.Title), RelativeSource={RelativeSource TemplatedParent},Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
HorizontalAlignment="{Binding Path=(hc:TitleElement.HorizontalAlignment), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
Margin="{Binding Path=(hc:TitleElement.MarginOnTheTop), RelativeSource={RelativeSource TemplatedParent}}">
|
||||||
|
<ContentPresenter DockPanel.Dock="Right"
|
||||||
|
TextElement.Foreground="{DynamicResource DangerBrush}"
|
||||||
|
Margin="4,0,0,0"
|
||||||
|
Content="{Binding Path=(hc:InfoElement.Symbol), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
IsVisible="{Binding Path=(hc:InfoElement.Necessary), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
<TextBlock TextWrapping="NoWrap"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
Text="{Binding Path=(hc:TitleElement.Title), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
</DockPanel>
|
||||||
|
<DataValidationErrors Grid.Row="1">
|
||||||
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}" />
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding PlaceholderText}" />
|
||||||
|
<ContentControl x:Name="ContentPresenter"
|
||||||
|
Content="{TemplateBinding SelectionBoxItem}"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||||
|
<Path Grid.Column="1"
|
||||||
|
IsVisible="{TemplateBinding IsDropDownOpen, Converter={x:Static BoolConverters.Not}}"
|
||||||
|
Data="{StaticResource DownGeometry}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="14"
|
||||||
|
Stretch="Uniform"
|
||||||
|
Fill="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Margin="{TemplateBinding Padding, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}" />
|
||||||
|
<Path Grid.Column="1"
|
||||||
|
IsVisible="{TemplateBinding IsDropDownOpen}"
|
||||||
|
Data="{StaticResource UpGeometry}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="14"
|
||||||
|
Stretch="Uniform"
|
||||||
|
Fill="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Margin="{TemplateBinding Padding, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}" />
|
||||||
|
<Popup Grid.Column="0"
|
||||||
|
Name="PART_Popup"
|
||||||
|
WindowManagerAddShadowHint="False"
|
||||||
|
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
|
||||||
|
PlacementTarget="border"
|
||||||
|
IsLightDismissEnabled="True"
|
||||||
|
InheritsTransform="True">
|
||||||
|
<Border x:Name="PopupBorder"
|
||||||
|
Background="{DynamicResource RegionBrush}"
|
||||||
|
BorderBrush="{DynamicResource BorderBrush}"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
Margin="8,0,8,8"
|
||||||
|
Effect="{StaticResource EffectShadow2}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}">
|
||||||
|
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||||
|
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||||
|
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||||
|
Margin="2">
|
||||||
|
<ItemsPresenter Name="PART_ItemsPresenter"
|
||||||
|
ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
</DataValidationErrors>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
|
||||||
|
<ControlTemplate x:Key="ComboBoxExtendLeftTemplate"
|
||||||
|
TargetType="ComboBox">
|
||||||
|
<Grid MinHeight="{Binding Path=(hc:InfoElement.MinContentHeight), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
Height="{Binding Path=(hc:InfoElement.ContentHeight), RelativeSource={RelativeSource TemplatedParent}}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="{Binding Path=(hc:TitleElement.TitleWidth), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<DockPanel LastChildFill="True"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
IsVisible="{Binding Path=(hc:TitleElement.Title), RelativeSource={RelativeSource TemplatedParent},Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
|
HorizontalAlignment="{Binding Path=(hc:TitleElement.HorizontalAlignment), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
VerticalAlignment="{Binding Path=(hc:TitleElement.VerticalAlignment), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
Margin="{Binding Path=(hc:TitleElement.MarginOnTheLeft), RelativeSource={RelativeSource TemplatedParent}}">
|
||||||
|
<ContentPresenter DockPanel.Dock="Right"
|
||||||
|
TextElement.Foreground="{DynamicResource DangerBrush}"
|
||||||
|
Margin="4,0,0,0"
|
||||||
|
Content="{Binding Path=(hc:InfoElement.Symbol), RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
IsVisible="{Binding Path=(hc:InfoElement.Necessary), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
<TextBlock TextWrapping="NoWrap"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
Text="{Binding Path=(hc:TitleElement.Title), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
</DockPanel>
|
||||||
|
<DataValidationErrors Grid.Column="1">
|
||||||
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}" />
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding PlaceholderText}" />
|
||||||
|
<ContentControl x:Name="ContentPresenter"
|
||||||
|
Content="{TemplateBinding SelectionBoxItem}"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||||
|
<Path Grid.Column="1"
|
||||||
|
IsVisible="{TemplateBinding IsDropDownOpen, Converter={x:Static BoolConverters.Not}}"
|
||||||
|
Data="{StaticResource DownGeometry}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="14"
|
||||||
|
Stretch="Uniform"
|
||||||
|
Fill="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Margin="{TemplateBinding Padding, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}" />
|
||||||
|
<Path Grid.Column="1"
|
||||||
|
IsVisible="{TemplateBinding IsDropDownOpen}"
|
||||||
|
Data="{StaticResource UpGeometry}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="14"
|
||||||
|
Stretch="Uniform"
|
||||||
|
Fill="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Margin="{TemplateBinding Padding, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}" />
|
||||||
|
<Popup Grid.Column="0"
|
||||||
|
Name="PART_Popup"
|
||||||
|
WindowManagerAddShadowHint="False"
|
||||||
|
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
|
||||||
|
PlacementTarget="border"
|
||||||
|
IsLightDismissEnabled="True"
|
||||||
|
InheritsTransform="True">
|
||||||
|
<Border x:Name="PopupBorder"
|
||||||
|
Background="{DynamicResource RegionBrush}"
|
||||||
|
BorderBrush="{DynamicResource BorderBrush}"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
Margin="8,0,8,8"
|
||||||
|
Effect="{StaticResource EffectShadow2}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}">
|
||||||
|
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||||
|
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||||
|
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||||
|
Margin="2">
|
||||||
|
<ItemsPresenter Name="PART_ItemsPresenter"
|
||||||
|
ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
</Grid>
|
||||||
|
</DataValidationErrors>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBoxExtendBaseStyle"
|
||||||
|
BasedOn="{StaticResource ComboBoxBaseStyle}"
|
||||||
|
TargetType="ComboBox">
|
||||||
|
<Setter Property="hc:InfoElement.Symbol"
|
||||||
|
Value="●" />
|
||||||
|
<Setter Property="hc:InfoElement.ContentHeight"
|
||||||
|
Value="{x:Static system:Double.NaN}" />
|
||||||
|
<Setter Property="hc:InfoElement.MinContentHeight"
|
||||||
|
Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="Template"
|
||||||
|
Value="{StaticResource ComboBoxExtendTopTemplate}" />
|
||||||
|
|
||||||
|
<Style Selector="^[(hc|TitleElement.TitlePlacement)=Left]">
|
||||||
|
<Setter Property="Template"
|
||||||
|
Value="{StaticResource ComboBoxExtendLeftTemplate}" />
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="{x:Type ComboBox}"
|
||||||
|
BasedOn="{StaticResource ComboBoxBaseStyle}"
|
||||||
|
TargetType="ComboBox" />
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBoxItem.Small"
|
||||||
|
BasedOn="{StaticResource ComboBoxItemBaseStyle}"
|
||||||
|
TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="20" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBox.Small"
|
||||||
|
BasedOn="{StaticResource ComboBoxBaseStyle}"
|
||||||
|
TargetType="ComboBox">
|
||||||
|
<Setter Property="ItemContainerTheme"
|
||||||
|
Value="{StaticResource ComboBoxItem.Small}" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBoxExtend"
|
||||||
|
BasedOn="{StaticResource ComboBoxExtendBaseStyle}"
|
||||||
|
TargetType="ComboBox" />
|
||||||
|
|
||||||
|
<ControlTheme x:Key="ComboBoxExtend.Small"
|
||||||
|
BasedOn="{StaticResource ComboBoxExtend}"
|
||||||
|
TargetType="ComboBox">
|
||||||
|
<Setter Property="ItemContainerTheme"
|
||||||
|
Value="{StaticResource ComboBoxItem.Small}" />
|
||||||
|
<Setter Property="hc:InfoElement.MinContentHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="hc:InfoElement.ContentHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheLeft"
|
||||||
|
Value="0,3,6,0" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheTop"
|
||||||
|
Value="6,0,0,1" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="20" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -48,6 +48,12 @@
|
|||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
Background="{TemplateBinding Background}" />
|
Background="{TemplateBinding Background}" />
|
||||||
|
<TextBlock VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding Watermark}" />
|
||||||
<ScrollViewer Name="PART_ScrollViewer"
|
<ScrollViewer Name="PART_ScrollViewer"
|
||||||
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||||
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
<MergeResourceInclude Source="/Themes/Styles/TextBox.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/TextBox.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/ButtonSpinner.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/ButtonSpinner.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/NumericUpDown.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/NumericUpDown.axaml" />
|
||||||
|
<MergeResourceInclude Source="/Themes/Styles/ComboBox.axaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Styles.Resources>
|
</Styles.Resources>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:hc="clr-namespace:HandyControl.Controls"
|
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
|
|
||||||
<!--默认下拉框模板-->
|
<!--默认下拉框模板-->
|
||||||
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="ComboBox">
|
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="ComboBox">
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -478,7 +478,7 @@
|
|||||||
<Condition Property="IsSelected" Value="True"/>
|
<Condition Property="IsSelected" Value="True"/>
|
||||||
</MultiTrigger.Conditions>
|
</MultiTrigger.Conditions>
|
||||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}"/>
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}"/>
|
||||||
<Setter Property="Foreground" Value="White"/>
|
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
|
||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -5620,7 +5620,7 @@
|
|||||||
<Condition Property="IsSelected" Value="True" />
|
<Condition Property="IsSelected" Value="True" />
|
||||||
</MultiTrigger.Conditions>
|
</MultiTrigger.Conditions>
|
||||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="Foreground" Value="White" />
|
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ public class InputElementDemoViewModel : ViewModelBase
|
|||||||
SelectedDataList = DataList.Where((t, i) => i % 2 == 0).ToList();
|
SelectedDataList = DataList.Where((t, i) => i % 2 == 0).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Search(string key)
|
private static void Search(string key)
|
||||||
{
|
{
|
||||||
Growl.Info(key);
|
Growl.Info(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetComboBoxDemoDataList()
|
private static List<string> GetComboBoxDemoDataList()
|
||||||
{
|
{
|
||||||
var converter = new StringRepeatConverter();
|
var converter = new StringRepeatConverter();
|
||||||
var list = new List<string>();
|
var list = new List<string>();
|
||||||
|
|||||||
@@ -517,7 +517,7 @@
|
|||||||
<Condition Property="IsSelected" Value="True" />
|
<Condition Property="IsSelected" Value="True" />
|
||||||
</MultiTrigger.Conditions>
|
</MultiTrigger.Conditions>
|
||||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="Foreground" Value="White" />
|
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -5662,7 +5662,7 @@
|
|||||||
<Condition Property="IsSelected" Value="True" />
|
<Condition Property="IsSelected" Value="True" />
|
||||||
</MultiTrigger.Conditions>
|
</MultiTrigger.Conditions>
|
||||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="Foreground" Value="White" />
|
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
Reference in new issue
Block a user