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", "", "" ],
|
||||
[ "NumericUpDown", "NumericUpDownDemo", "Brush.NumericListBox", "", "" ],
|
||||
[ "TextBox", "TextBoxDemo", "Brush.TextBox", "", "" ],
|
||||
[ "ComboBox", "NativeComboBoxDemo", "Brush.ComboBox", "", "" ],
|
||||
[ "ComboBox", "ComboBoxDemo", "Brush.ComboBox", "", "" ],
|
||||
[ "Expander", "ExpanderDemo", "Brush.Expander", "", "" ],
|
||||
[ "ProgressBar", "NativeProgressBarDemo", "Brush.ProgressBar", "", "" ],
|
||||
[ "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.Globalization;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using HandyControlDemo.Properties.Langs;
|
||||
using HandyControlDemo.Tools.Converter;
|
||||
|
||||
namespace HandyControlDemo.ViewModel;
|
||||
|
||||
@@ -20,4 +24,23 @@ public partial class InputElementDemoViewModel : ObservableValidator
|
||||
[ObservableProperty] private double? _doubleValue1;
|
||||
|
||||
[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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user