feat: add disable container.

This commit is contained in:
rabbitism
2024-02-15 02:50:48 +08:00
parent e286f3fece
commit 7102a63fe8
9 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:shapes="clr-namespace:Ursa.Controls.Shapes;assembly=Ursa">
<!-- Add Resources Here -->
<ControlTheme TargetType="u:DisableContainer" x:Key="{x:Type u:DisableContainer}">
<Setter Property="Template">
<ControlTemplate TargetType="u:DisableContainer">
<Panel>
<ContentPresenter Content="{TemplateBinding Content}"></ContentPresenter>
<shapes:PureRectangle Background="Transparent" IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.IsEnabled, Converter={x:Static BoolConverters.Not}}" Cursor="No" ToolTip.Tip="{TemplateBinding DisabledTip}"/>
</Panel>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

View File

@@ -7,6 +7,7 @@
<ResourceInclude Source="ControlClassesInput.axaml" />
<ResourceInclude Source="Dialog.axaml" />
<ResourceInclude Source="DialogShared.axaml" />
<ResourceInclude Source="DisableContainer.axaml" />
<ResourceInclude Source="Divider.axaml" />
<ResourceInclude Source="Drawer.axaml" />
<ResourceInclude Source="DualBadge.axaml" />

View File

@@ -0,0 +1,29 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Metadata;
namespace Ursa.Controls;
public class DisableContainer: TemplatedControl
{
public static readonly StyledProperty<InputElement?> ContentProperty = AvaloniaProperty.Register<DisableContainer, InputElement?>(
nameof(Content));
[Content]
public InputElement? Content
{
get => GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}
public static readonly StyledProperty<object?> DisabledTipProperty = AvaloniaProperty.Register<DisableContainer, object?>(
nameof(DisabledTip));
public object? DisabledTip
{
get => GetValue(DisabledTipProperty);
set => SetValue(DisabledTipProperty, value);
}
}