feat: initialize Rating.
This commit is contained in:
114
demo/Ursa.Demo/Pages/RatingDemo.axaml
Normal file
114
demo/Ursa.Demo/Pages/RatingDemo.axaml
Normal file
@@ -0,0 +1,114 @@
|
||||
<UserControl x:Class="Ursa.Demo.Pages.RatingDemo"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:RatingDemoViewModel"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel Spacing="20">
|
||||
<Grid ColumnDefinitions="*, 300">
|
||||
<Grid Grid.Column="0">
|
||||
<StackPanel>
|
||||
<u:RatingCharacter />
|
||||
<u:Rating
|
||||
AllowClear="{Binding AllowClear }"
|
||||
AllowHalf="{Binding AllowHalf }"
|
||||
AllowFocus="{Binding AllowFocus }"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
Value="{Binding Value}"
|
||||
Count="{Binding Count}"
|
||||
DefaultValue="{Binding DefaultValue }"
|
||||
Tooltips="{Binding Tooltips }" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Grid.Column="1" VerticalAlignment="Top">
|
||||
<Grid ColumnDefinitions="*, Auto" RowDefinitions="*,*,*,*,*,*,*">
|
||||
<Label
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="AllowClear" />
|
||||
<ToggleSwitch
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
MinWidth="200"
|
||||
IsChecked="{Binding AllowClear}" />
|
||||
<Label
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="AllowHalf" />
|
||||
<ToggleSwitch
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding AllowHalf}" />
|
||||
<Label
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="AllowFocus" />
|
||||
<ToggleSwitch
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding AllowFocus}" />
|
||||
<Label
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="IsEnabled" />
|
||||
<ToggleSwitch
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding IsEnabled}" />
|
||||
<Label
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Value" />
|
||||
<NumericUpDown
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Maximum="100"
|
||||
Minimum="-1"
|
||||
Increment="0.1"
|
||||
VerticalAlignment="Center"
|
||||
Value="{Binding Value}" />
|
||||
<Label
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Count" />
|
||||
<NumericUpDown
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Maximum="100"
|
||||
Minimum="-1"
|
||||
Increment="1"
|
||||
VerticalAlignment="Center"
|
||||
Value="{Binding Count}" />
|
||||
<Label
|
||||
Grid.Row="6"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="DefaultValue" />
|
||||
<NumericUpDown
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
Maximum="100"
|
||||
Minimum="-1"
|
||||
Increment="0.1"
|
||||
VerticalAlignment="Center"
|
||||
Value="{Binding DefaultValue}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Pages/RatingDemo.axaml.cs
Normal file
13
demo/Ursa.Demo/Pages/RatingDemo.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia.Controls;
|
||||
using Ursa.Demo.ViewModels;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class RatingDemo : UserControl
|
||||
{
|
||||
public RatingDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new RatingDemoViewModel();
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ public class MainViewViewModel : ViewModelBase
|
||||
MenuKeys.MenuKeyNumPad => new NumPadDemoViewModel(),
|
||||
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
||||
MenuKeys.MenuKeyRangeSlider => new RangeSliderDemoViewModel(),
|
||||
MenuKeys.MenuKeyRating => new RatingDemoViewModel(),
|
||||
MenuKeys.MenuKeyScrollToButton => new ScrollToButtonDemoViewModel(),
|
||||
MenuKeys.MenuKeySelectionList => new SelectionListDemoViewModel(),
|
||||
MenuKeys.MenuKeySkeleton => new SkeletonDemoViewModel(),
|
||||
|
||||
@@ -38,6 +38,7 @@ public class MenuViewModel: ViewModelBase
|
||||
new() { MenuHeader = "NumPad", Key = MenuKeys.MenuKeyNumPad },
|
||||
new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination },
|
||||
new() { MenuHeader = "RangeSlider", Key = MenuKeys.MenuKeyRangeSlider },
|
||||
new() { MenuHeader = "Rating", Key = MenuKeys.MenuKeyRating },
|
||||
new() { MenuHeader = "Scroll To", Key = MenuKeys.MenuKeyScrollToButton },
|
||||
new() { MenuHeader = "Selection List", Key = MenuKeys.MenuKeySelectionList },
|
||||
new() { MenuHeader = "Skeleton", Key = MenuKeys.MenuKeySkeleton },
|
||||
@@ -83,6 +84,7 @@ public static class MenuKeys
|
||||
public const string MenuKeyNumPad = "NumPad";
|
||||
public const string MenuKeyPagination = "Pagination";
|
||||
public const string MenuKeyRangeSlider = "RangeSlider";
|
||||
public const string MenuKeyRating = "Rating";
|
||||
public const string MenuKeyScrollToButton = "ScrollToButton";
|
||||
public const string MenuKeySelectionList = "SelectionList";
|
||||
public const string MenuKeyTagInput = "TagInput";
|
||||
|
||||
20
demo/Ursa.Demo/ViewModels/RatingDemoViewModel.cs
Normal file
20
demo/Ursa.Demo/ViewModels/RatingDemoViewModel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public partial class RatingDemoViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty] private bool _allowClear = true;
|
||||
[ObservableProperty] private bool _allowHalf = true;
|
||||
[ObservableProperty] private bool _allowFocus;
|
||||
[ObservableProperty] private bool _isEnabled = true;
|
||||
|
||||
[ObservableProperty] private double _value;
|
||||
|
||||
// [ObservableProperty] private object _character;
|
||||
[ObservableProperty] private int _count = 10;
|
||||
[ObservableProperty] private double _defaultValue = 5;
|
||||
|
||||
public ObservableCollection<string> Tooltips { get; set; } = ["1", "2", "3", "4", "5"];
|
||||
}
|
||||
Reference in New Issue
Block a user