committed by
GitHub
18 changed files with 320 additions and 44 deletions
@ -1,5 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.3" /> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,15 +1,28 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui"> |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<StackPanel Orientation="Vertical" Gap="4"> |
|||
<TextBlock Classes="h1">CheckBox</TextBlock> |
|||
<TextBlock Classes="h2">A check box control</TextBlock> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
<StackPanel Orientation="Horizontal" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Gap="16"> |
|||
<CheckBox>Unchecked</CheckBox> |
|||
<CheckBox IsChecked="True">Checked</CheckBox> |
|||
<CheckBox IsChecked="True" IsEnabled="False">Disabled</CheckBox> |
|||
</StackPanel> |
|||
<StackPanel Orientation="Vertical" |
|||
Gap="16"> |
|||
<CheckBox>Unchecked</CheckBox> |
|||
<CheckBox IsChecked="True">Checked</CheckBox> |
|||
<CheckBox IsChecked="{x:Null}">Indeterminate</CheckBox> |
|||
<CheckBox IsChecked="True" IsEnabled="False">Disabled</CheckBox> |
|||
</StackPanel> |
|||
<StackPanel Orientation="Vertical" |
|||
HorizontalAlignment="Center" |
|||
Gap="16"> |
|||
<CheckBox IsChecked="False" IsThreeState="True">Three State: Unchecked</CheckBox> |
|||
<CheckBox IsChecked="True" IsThreeState="True">Three State: Checked</CheckBox> |
|||
<CheckBox IsChecked="{x:Null}" IsThreeState="True">Three State: Indeterminate</CheckBox> |
|||
<CheckBox IsChecked="{x:Null}" IsThreeState="True" IsEnabled="False">Three State: Disabled</CheckBox> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -1,15 +1,27 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui"> |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<StackPanel Orientation="Vertical" Gap="4"> |
|||
<TextBlock Classes="h1">RadioButton</TextBlock> |
|||
<TextBlock Classes="h2">Allows the selection of a single option of many</TextBlock> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
<StackPanel Orientation="Horizontal" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Gap="16"> |
|||
<RadioButton IsChecked="True">Option 1</RadioButton> |
|||
<RadioButton>Option 2</RadioButton> |
|||
<RadioButton IsEnabled="False">Disabled</RadioButton> |
|||
</StackPanel> |
|||
<StackPanel Orientation="Vertical" |
|||
Gap="16"> |
|||
<RadioButton IsChecked="True">Option 1</RadioButton> |
|||
<RadioButton>Option 2</RadioButton> |
|||
<RadioButton IsChecked="{x:Null}">Option 3</RadioButton> |
|||
<RadioButton IsEnabled="False">Disabled</RadioButton> |
|||
</StackPanel> |
|||
<StackPanel Orientation="Vertical" |
|||
Gap="16"> |
|||
<RadioButton IsChecked="True" IsThreeState="True">Three States: Option 1</RadioButton> |
|||
<RadioButton IsChecked="False" IsThreeState="True">Three States: Option 2</RadioButton> |
|||
<RadioButton IsChecked="{x:Null}" IsThreeState="True">Three States: Option 3</RadioButton> |
|||
<RadioButton IsChecked="{x:Null}" IsThreeState="True" IsEnabled="False">Disabled</RadioButton> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,57 @@ |
|||
using Avalonia.Markup.Xaml.Data; |
|||
using Avalonia.UnitTests; |
|||
|
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Controls.Primitives.UnitTests |
|||
{ |
|||
public class ToggleButtonTests |
|||
{ |
|||
private const string uncheckedClass = ":unchecked"; |
|||
private const string checkedClass = ":checked"; |
|||
private const string indeterminateClass = ":indeterminate"; |
|||
|
|||
[Theory] |
|||
[InlineData(false, uncheckedClass, false)] |
|||
[InlineData(false, uncheckedClass, true)] |
|||
[InlineData(true, checkedClass, false)] |
|||
[InlineData(true, checkedClass, true)] |
|||
[InlineData(null, indeterminateClass, false)] |
|||
[InlineData(null, indeterminateClass, true)] |
|||
public void ToggleButton_Has_Correct_Class_According_To_Is_Checked(bool? isChecked, string expectedClass, bool isThreeState) |
|||
{ |
|||
var toggleButton = new ToggleButton(); |
|||
toggleButton.IsThreeState = isThreeState; |
|||
toggleButton.IsChecked = isChecked; |
|||
|
|||
Assert.Contains(expectedClass, toggleButton.Classes); |
|||
} |
|||
|
|||
[Fact] |
|||
public void ToggleButton_Is_Checked_Binds_To_Bool() |
|||
{ |
|||
var toggleButton = new ToggleButton(); |
|||
var source = new Class1(); |
|||
|
|||
toggleButton.DataContext = source; |
|||
toggleButton.Bind(ToggleButton.IsCheckedProperty, new Binding("Foo")); |
|||
|
|||
source.Foo = true; |
|||
Assert.True(toggleButton.IsChecked); |
|||
|
|||
source.Foo = false; |
|||
Assert.False(toggleButton.IsChecked); |
|||
} |
|||
|
|||
private class Class1 : NotifyingBase |
|||
{ |
|||
private bool _foo; |
|||
|
|||
public bool Foo |
|||
{ |
|||
get { return _foo; } |
|||
set { _foo = value; RaisePropertyChanged(); } |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using Avalonia.Markup.Xaml.Data; |
|||
using Avalonia.UnitTests; |
|||
|
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Controls.UnitTests |
|||
{ |
|||
public class RadioButtonTests |
|||
{ |
|||
[Theory] |
|||
[InlineData(false)] |
|||
[InlineData(true)] |
|||
public void Indeterminate_RadioButton_Is_Not_Unchecked_After_Checking_Other_Radio_Button(bool isThreeState) |
|||
{ |
|||
var panel = new Panel(); |
|||
|
|||
var radioButton1 = new RadioButton(); |
|||
radioButton1.IsThreeState = false; |
|||
radioButton1.IsChecked = false; |
|||
|
|||
var radioButton2 = new RadioButton(); |
|||
radioButton2.IsThreeState = isThreeState; |
|||
radioButton2.IsChecked = null; |
|||
|
|||
panel.Children.Add(radioButton1); |
|||
panel.Children.Add(radioButton2); |
|||
|
|||
Assert.Null(radioButton2.IsChecked); |
|||
|
|||
radioButton1.IsChecked = true; |
|||
|
|||
Assert.True(radioButton1.IsChecked); |
|||
Assert.Null(radioButton2.IsChecked); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue