Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Avalonia/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TargetFramework>net9.0</TargetFramework>
<AvaloniaVersion>11.3.6</AvaloniaVersion>
<AvaloniaVersion>12.0.1</AvaloniaVersion>
</PropertyGroup>
</Project>
14 changes: 0 additions & 14 deletions src/Avalonia/HandyControlDemo_Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public override void Initialize()
public override void OnFrameworkInitializationCompleted()
{
Properties.Langs.Lang.Culture = new CultureInfo("en");
RemoveDefaultDataValidator();

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
Expand All @@ -27,17 +26,4 @@ public override void OnFrameworkInitializationCompleted()

base.OnFrameworkInitializationCompleted();
}

private static void RemoveDefaultDataValidator()
{
// Get an array of plugins to remove
var dataValidationPluginsToRemove =
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();

// remove each entry found
foreach (var plugin in dataValidationPluginsToRemove)
{
BindingPlugins.DataValidators.Remove(plugin);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:HandyControlDemo.Data"
xmlns:vm="using:HandyControlDemo.ViewModel"
x:DataType="{x:Type vm:MainViewModel}"
Margin="16,16,0,16"
CornerRadius="10"
Effect="{StaticResource EffectShadow4}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<UserControl x:Class="HandyControlDemo.UserControl.MainContent"
xmlns="https://github.com/avaloniaui"
xmlns:vm="using:HandyControlDemo.ViewModel"
x:DataType="{x:Type vm:MainViewModel}"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Panel>
<Border Margin="16">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:data="using:HandyControlDemo.Data"
x:DataType="{x:Type data:DemoDataModel}"
x:Class="HandyControlDemo.UserControl.AutoCompleteBoxDemo">
<ScrollViewer>
<hc:UniformSpacingPanel Spacing="32"
Expand Down Expand Up @@ -36,7 +38,7 @@
FilterMode="Contains"
Margin="0,16,0,0"
IsEnabled="False" />
<AutoCompleteBox Watermark="please enter content"
<AutoCompleteBox PlaceholderText="please enter content"
hc:TitleElement.Title="This item must be filled in"
Theme="{StaticResource AutoCompleteBoxExtend}"
ItemsSource="{Binding DataList}"
Expand All @@ -55,7 +57,7 @@
Margin="0,32,0,0" />
<AutoCompleteBox Width="380"
hc:TitleElement.TitleWidth="120"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
hc:InfoElement.Necessary="True"
Expand Down Expand Up @@ -97,7 +99,7 @@
FilterMode="Contains"
Margin="0,16,0,0"
IsEnabled="False" />
<AutoCompleteBox Watermark="please enter content"
<AutoCompleteBox PlaceholderText="please enter content"
hc:TitleElement.Title="This item must be filled in"
Theme="{StaticResource AutoCompleteBoxExtend.Small}"
ItemsSource="{Binding DataList}"
Expand All @@ -116,7 +118,7 @@
Margin="0,32,0,0" />
<AutoCompleteBox Width="380"
hc:TitleElement.TitleWidth="120"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
hc:InfoElement.Necessary="True"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<UserControl xmlns="https://github.com/avaloniaui"
<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>
x:DataType="vm:InputElementDemoViewModel"
x:CompileBindings="False"
DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}"
>
<ScrollViewer >
<hc:UniformSpacingPanel Spacing="32"
Margin="32"
ChildWrapping="Wrap">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="using:HandyControlDemo.Data"
x:DataType="{x:Type data:DemoDataModel}"
x:Class="HandyControlDemo.UserControl.ListBoxDemo">
<WrapPanel Margin="16">
<ListBox Margin="16"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:data="using:HandyControlDemo.Data"
x:DataType="{x:Type data:DemoDataModel}"
x:Class="HandyControlDemo.UserControl.MenuDemo">
<hc:UniformSpacingPanel Spacing="16"
Margin="32">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui"
<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.NumericUpDownDemo"
x:DataType="{x:Type vm:InputElementDemoViewModel}"
x:CompileBindings="False"
DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}">
<ScrollViewer>
<hc:UniformSpacingPanel Spacing="32"
Expand All @@ -21,7 +23,7 @@
hc:TitleElement.Title="This is the title"
Theme="{StaticResource NumericUpDownExtend}" />
<NumericUpDown Value="0"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.Title="This is the title"
hc:InfoElement.Necessary="True"
Theme="{StaticResource NumericUpDownExtend}" />
Expand All @@ -36,7 +38,7 @@
Value="10000"
Width="380"
hc:TitleElement.TitleWidth="140"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
Theme="{StaticResource NumericUpDownExtend}"
Expand All @@ -59,7 +61,7 @@
hc:TitleElement.Title="This is the title"
Theme="{StaticResource NumericUpDownExtend}" />
<NumericUpDown Value="0"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.Title="This is the title"
hc:InfoElement.Necessary="True"
Theme="{StaticResource NumericUpDownExtend}" />
Expand All @@ -74,7 +76,7 @@
hc:InfoElement.ShowClearButton="True"
Width="380"
hc:TitleElement.TitleWidth="140"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
Theme="{StaticResource NumericUpDownExtend}"
Expand All @@ -96,7 +98,7 @@
hc:TitleElement.Title="This is the title"
Theme="{StaticResource NumericUpDownExtend.Small}" />
<NumericUpDown Value="0"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.Title="This is the title"
hc:InfoElement.Necessary="True"
Theme="{StaticResource NumericUpDownExtend.Small}" />
Expand All @@ -111,7 +113,7 @@
Value="10000"
Width="380"
hc:TitleElement.TitleWidth="140"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
Theme="{StaticResource NumericUpDownExtend.Small}"
Expand All @@ -134,7 +136,7 @@
hc:TitleElement.Title="This is the title"
Theme="{StaticResource NumericUpDownExtend.Small}" />
<NumericUpDown Value="0"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.Title="This is the title"
hc:InfoElement.Necessary="True"
Theme="{StaticResource NumericUpDownExtend.Small}" />
Expand All @@ -149,7 +151,7 @@
hc:InfoElement.ShowClearButton="True"
Width="380"
hc:TitleElement.TitleWidth="140"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
Theme="{StaticResource NumericUpDownExtend.Small}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui"
<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.TextBoxDemo"
x:DataType="{x:Type vm:InputElementDemoViewModel}"
x:CompileBindings="False"
DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}">
<ScrollViewer>
<hc:UniformSpacingPanel Spacing="32"
Expand All @@ -28,7 +30,7 @@
Margin="0,16,0,0"
Text="This is the content"
IsEnabled="False" />
<TextBox Watermark="please enter email"
<TextBox PlaceholderText="please enter email"
Text="{Binding Email1, UpdateSourceTrigger=PropertyChanged}"
hc:TitleElement.Title="This item must be filled in"
Theme="{StaticResource TextBoxExtend}"
Expand All @@ -44,7 +46,7 @@
<TextBox Width="380"
Text="{Binding Text1, UpdateSourceTrigger=PropertyChanged}"
hc:TitleElement.TitleWidth="120"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
hc:InfoElement.Necessary="True"
Expand Down Expand Up @@ -74,7 +76,7 @@
Margin="0,16,0,0"
Text="This is the content"
IsEnabled="False" />
<TextBox Watermark="please enter email"
<TextBox PlaceholderText="please enter email"
Text="{Binding Email2, UpdateSourceTrigger=PropertyChanged}"
hc:TitleElement.Title="This item must be filled in"
Theme="{StaticResource TextBoxExtend.Small}"
Expand All @@ -90,7 +92,7 @@
<TextBox Width="380"
Text="{Binding Text2, UpdateSourceTrigger=PropertyChanged}"
hc:TitleElement.TitleWidth="120"
Watermark="Please enter content"
PlaceholderText="Please enter content"
hc:TitleElement.TitlePlacement="Left"
hc:TitleElement.Title="The title is on the left"
hc:InfoElement.Necessary="True"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui"
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="using:HandyControlDemo.Data"
x:DataType="{x:Type data:DemoDataModel}"
x:Class="HandyControlDemo.UserControl.TreeViewDemo">
<WrapPanel Margin="16">
<TreeView Width="200"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
Expand Down Expand Up @@ -145,7 +145,7 @@ private Thickness LayoutThickness
Thickness thickness = BorderThickness;
if (UseLayoutRounding)
{
thickness = LayoutHelper.RoundLayoutThickness(thickness, _scale, _scale);
thickness = LayoutHelper.RoundLayoutThickness(thickness, _scale);
}

_layoutThickness = thickness;
Expand Down
41 changes: 41 additions & 0 deletions src/Avalonia/HandyControl_Avalonia/Controls/Panel/SimplePanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using Avalonia;
using Avalonia.Controls;

namespace HandyControl.Controls;

/// <summary>
/// 用以代替Grid
/// </summary>
/// <remarks>
/// 当不需要Grid的行、列分隔等功能时建议用此轻量级类代替
/// </remarks>
public class SimplePanel : Panel
{
protected override Size MeasureOverride(Size constraint)
{
var maxWidth = 0d;
var maxHeight = 0d;
foreach (Control? child in Children)
{
if (child != null)
{
child.Measure(constraint);
maxWidth = Math.Max(maxWidth, child.DesiredSize.Width);
maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
}
}

return new Size(maxWidth, maxHeight);
}

protected override Size ArrangeOverride(Size arrangeSize)
{
foreach (Control? child in Children)
{
child?.Arrange(new Rect(arrangeSize));
}

return arrangeSize;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal"
xmlns:hc="clr-namespace:HandyControl.Controls"
Expand Down Expand Up @@ -41,7 +41,7 @@
CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}"
ClearSelectionOnLostFocus="{TemplateBinding ClearSelectionOnLostFocus}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Watermark="{TemplateBinding Watermark}"
PlaceholderText="{TemplateBinding PlaceholderText}"
MaxLength="{TemplateBinding MaxLength}" />
<Popup Name="PART_Popup"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
Expand Down Expand Up @@ -95,7 +95,7 @@
Value="{StaticResource DefaultControlHeight}" />
<Setter Property="Template">
<ControlTemplate>
<HeaderedContentControl Header="{Binding $parent.(hc:TitleElement.Title)}">
<HeaderedContentControl Header="{Binding $parent[AutoCompleteBox].(hc:TitleElement.Title)}">
<Panel>
<TextBox Name="PART_TextBox"
Padding="{TemplateBinding Padding}"
Expand All @@ -107,7 +107,7 @@
CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}"
ClearSelectionOnLostFocus="{TemplateBinding ClearSelectionOnLostFocus}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Watermark="{TemplateBinding Watermark}"
PlaceholderText="{TemplateBinding PlaceholderText}"
MaxLength="{TemplateBinding MaxLength}" />
<Popup Name="PART_Popup"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal"
xmlns:hc="clr-namespace:HandyControl.Controls"
Expand Down Expand Up @@ -225,7 +225,7 @@
Value="{StaticResource DefaultControlHeight}" />
<Setter Property="Template">
<ControlTemplate>
<HeaderedContentControl Header="{Binding $parent.(hc:TitleElement.Title)}">
<HeaderedContentControl Header="{Binding $parent[ComboBox].(hc:TitleElement.Title)}">
<Grid ColumnDefinitions="*,Auto,Auto">
<Border x:Name="border"
Grid.ColumnSpan="3"
Expand Down
Loading