123
demo/Ursa.Demo/Pages/RatingDemo.axaml
Normal file
123
demo/Ursa.Demo/Pages/RatingDemo.axaml
Normal file
@@ -0,0 +1,123 @@
|
||||
<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">
|
||||
<UserControl.Resources>
|
||||
<StreamGeometry x:Key="LoveHeartGeometry">
|
||||
M12 5.99999C10.5 2.12432 5.75193 2.0557 3.40383 4.4038C0.865423 6.94221 0.999999 10.5 3.50001 14C5.52139 16.8299 9.83088 20.3136 11.4069 21.5438C11.7573 21.8172 12.2427 21.8172 12.5931 21.5438C14.1691 20.3136 18.4786 16.8299 20.5 14C23 10.5 23.1346 6.94221 20.5962 4.4038C18.2481 2.0557 14.5 2.12432 12 5.99999Z
|
||||
</StreamGeometry>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Spacing="20">
|
||||
<Grid ColumnDefinitions="*, 300">
|
||||
<Grid Grid.Column="0">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<u:Rating
|
||||
AllowClear="{Binding AllowClear}"
|
||||
AllowHalf="{Binding AllowHalf}"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
Value="{Binding Value}"
|
||||
Count="{Binding Count}"
|
||||
DefaultValue="{Binding DefaultValue}" />
|
||||
<u:Rating
|
||||
Classes="Small"
|
||||
AllowClear="{Binding AllowClear}"
|
||||
AllowHalf="{Binding AllowHalf}"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
Value="{Binding Value}"
|
||||
Count="{Binding Count}"
|
||||
DefaultValue="{Binding DefaultValue}" />
|
||||
<u:Rating
|
||||
Size="48"
|
||||
AllowClear="{Binding AllowClear}"
|
||||
AllowHalf="{Binding AllowHalf}"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
Value="{Binding Value}"
|
||||
Count="{Binding Count}"
|
||||
DefaultValue="{Binding DefaultValue}"
|
||||
Foreground="{StaticResource SemiRed5}"
|
||||
Character="{StaticResource LoveHeartGeometry}" />
|
||||
</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="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="DefaultValue" />
|
||||
<Label
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Theme="{StaticResource TagLabel}"
|
||||
Classes="Large"
|
||||
VerticalAlignment="Center"
|
||||
Content="{Binding DefaultValue}" />
|
||||
<Label
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Value" />
|
||||
<NumericUpDown
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Maximum="100"
|
||||
Minimum="-10"
|
||||
Increment="0.1"
|
||||
VerticalAlignment="Center"
|
||||
Value="{Binding Value}" />
|
||||
<Label
|
||||
Grid.Row="6"
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Count" />
|
||||
<NumericUpDown
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
Maximum="100"
|
||||
Minimum="-10"
|
||||
Increment="1"
|
||||
VerticalAlignment="Center"
|
||||
Value="{Binding Count}" />
|
||||
</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, Status = "New"},
|
||||
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";
|
||||
|
||||
13
demo/Ursa.Demo/ViewModels/RatingDemoViewModel.cs
Normal file
13
demo/Ursa.Demo/ViewModels/RatingDemoViewModel.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
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 _isEnabled = true;
|
||||
[ObservableProperty] private double _value;
|
||||
[ObservableProperty] private double _defaultValue = 2.3;
|
||||
[ObservableProperty] private int _count = 5;
|
||||
}
|
||||
Reference in New Issue
Block a user