2 changed files with 34 additions and 24 deletions
@ -1,28 +1,25 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.CheckBoxPage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h2">A check box control</TextBlock> |
|||
x:Class="ControlCatalog.Pages.CheckBoxPage" Background="White"> |
|||
<Grid> |
|||
<TextBlock x:Name="myTb" /> |
|||
<ToggleButton x:Name="TogglePopupButton" Height="30" Width="150" HorizontalAlignment="Left"> |
|||
<StackPanel> |
|||
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center"> |
|||
<Run Text="Is button toggled? " /> |
|||
<Run Text="{Binding IsChecked, ElementName=TogglePopupButton}" /> |
|||
</TextBlock> |
|||
|
|||
<StackPanel Orientation="Horizontal" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Spacing="16"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="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" |
|||
Spacing="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> |
|||
<Popup Name="myPopup" IsOpen="{Binding IsChecked, ElementName=TogglePopupButton}"> |
|||
<Panel> |
|||
<Border BorderThickness="1" IsHitTestVisible="False" Margin="0" BorderBrush="Red" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" /> |
|||
|
|||
<TextBlock Name="myPopupText" Background="LightBlue" Foreground="Blue" Padding="30" Margin="150"> |
|||
Popup Text |
|||
</TextBlock> |
|||
</Panel> |
|||
</Popup> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</ToggleButton> |
|||
</Grid> |
|||
</UserControl> |
|||
|
|||
@ -1,18 +1,31 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class CheckBoxPage : UserControl |
|||
public partial class CheckBoxPage : UserControl |
|||
{ |
|||
private TextBlock myTb; |
|||
|
|||
public CheckBoxPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
|
|||
myTb = this.FindControl<TextBlock>("myTb"); |
|||
|
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
protected override void OnPointerMoved(PointerEventArgs e) |
|||
{ |
|||
base.OnPointerMoved(e); |
|||
|
|||
myTb.Text = e.GetPosition(this).ToString(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue