feat: basic shape.
This commit is contained in:
@@ -3,7 +3,14 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
|
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Ursa.Demo.Pages.AvatarDemo">
|
x:Class="Ursa.Demo.Pages.AvatarDemo">
|
||||||
<u:Avatar />
|
<Design.DataContext>
|
||||||
|
<vm:AvatarDemoViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<StackPanel>
|
||||||
|
<u:Avatar Content="{Binding Content}"
|
||||||
|
Command="{Binding ClickCommand}"/>
|
||||||
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,6 +1,16 @@
|
|||||||
namespace Ursa.Demo.ViewModels;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
public class AvatarDemoViewModel: ViewModelBase
|
namespace Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
|
public partial class AvatarDemoViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
[ObservableProperty] private string _content = "AS";
|
||||||
|
[ObservableProperty] private bool _canClick = true;
|
||||||
|
|
||||||
|
[RelayCommand(CanExecute = nameof(CanClick))]
|
||||||
|
private void Click()
|
||||||
|
{
|
||||||
|
Content = "BM";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,30 @@
|
|||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:u="https://irihi.tech/ursa">
|
xmlns:u="https://irihi.tech/ursa">
|
||||||
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}" />
|
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}">
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="Background" Value="{DynamicResource SemiGrey3Color}" />
|
||||||
|
<Setter Property="FontSize" Value="20" />
|
||||||
|
<Setter Property="Height" Value="48" />
|
||||||
|
<Setter Property="Width" Value="48" />
|
||||||
|
<Setter Property="Cursor" Value="Hand" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="{x:Type u:Avatar}">
|
||||||
|
<Panel>
|
||||||
|
<Ellipse Fill="{TemplateBinding Background}" />
|
||||||
|
<ContentPresenter
|
||||||
|
Name="PART_ContentPresenter"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center" />
|
||||||
|
<DockPanel>
|
||||||
|
<ContentPresenter DockPanel.Dock="Top" />
|
||||||
|
<ContentPresenter DockPanel.Dock="Bottom" />
|
||||||
|
</DockPanel>
|
||||||
|
</Panel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
<ControlTheme x:Key="{x:Type u:AvatarGroup}" TargetType="{x:Type u:AvatarGroup}" />
|
<ControlTheme x:Key="{x:Type u:AvatarGroup}" TargetType="{x:Type u:AvatarGroup}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
Reference in New Issue
Block a user