提交用户部分代码
This commit is contained in:
1 parent
9b9e4cbd82
commit
127fc22de5
26 files changed
+1110
-206
No files matched your search
@@ -602,7 +602,6 @@
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
AutomationProperties.Name="全选行"
|
||||
Command="{x:Static ext:DataGridEx.ToggleSelectAllCommand}"
|
||||
CommandTarget="{Binding RelativeSource={RelativeSource AncestorType={x:Type ext:DataGridEx}}}"
|
||||
IsChecked="{Binding AreAllRowsSelected, RelativeSource={RelativeSource AncestorType={x:Type ext:DataGridEx}}, Mode=OneWay}">
|
||||
@@ -992,7 +991,6 @@
|
||||
<CheckBox
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
AutomationProperties.Name="选择行"
|
||||
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Style="{StaticResource DataGridExCheckBoxStyle}" />
|
||||
</Border>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Store.Management.Framework.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="DialogWindow"
|
||||
Title="{Binding Title}"
|
||||
Width="800"
|
||||
Height="450"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
using MAX.Common.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Store.Management.Framework.Controls
|
||||
{
|
||||
internal class HorizontalIconText : Control
|
||||
{
|
||||
|
||||
public string Icon
|
||||
{
|
||||
get => (string)GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
|
||||
nameof(Icon),
|
||||
typeof(string),
|
||||
typeof(HorizontalIconText),
|
||||
new PropertyMetadata(null, OnOnIconChanged)
|
||||
);
|
||||
|
||||
public bool ShowIcon
|
||||
{
|
||||
get => (bool)GetValue(ShowIconProperty);
|
||||
private set => SetValue(ShowIconPropertyKey, value);
|
||||
}
|
||||
|
||||
private static readonly DependencyPropertyKey ShowIconPropertyKey = DependencyProperty.RegisterReadOnly(
|
||||
nameof(ShowIcon),
|
||||
typeof(bool),
|
||||
typeof(HorizontalIconText),
|
||||
new PropertyMetadata(false)
|
||||
);
|
||||
|
||||
public static readonly DependencyProperty ShowIconProperty = ShowIconPropertyKey.DependencyProperty;
|
||||
|
||||
|
||||
|
||||
|
||||
public bool ShowSpace
|
||||
{
|
||||
get => (bool)GetValue(ShowSpaceProperty);
|
||||
private set => SetValue(ShowSpacePropertyKey, value);
|
||||
}
|
||||
|
||||
private static readonly DependencyPropertyKey ShowSpacePropertyKey = DependencyProperty.RegisterReadOnly(
|
||||
nameof(ShowSpace),
|
||||
typeof(bool),
|
||||
typeof(HorizontalIconText),
|
||||
new PropertyMetadata(true)
|
||||
);
|
||||
|
||||
public static readonly DependencyProperty ShowSpaceProperty = ShowSpacePropertyKey.DependencyProperty;
|
||||
|
||||
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => (string)GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||
nameof(Text),
|
||||
typeof(string),
|
||||
typeof(HorizontalIconText),
|
||||
new PropertyMetadata(string.Empty)
|
||||
);
|
||||
|
||||
|
||||
|
||||
public double IconSize
|
||||
{
|
||||
get => (double)GetValue(IconSizeProperty);
|
||||
set => SetValue(IconSizeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IconSizeProperty = DependencyProperty.Register(
|
||||
nameof(IconSize),
|
||||
typeof(double),
|
||||
typeof(HorizontalIconText),
|
||||
new PropertyMetadata(14d)
|
||||
);
|
||||
|
||||
|
||||
|
||||
public double Spacing
|
||||
{
|
||||
get => (double)GetValue(SpacingProperty);
|
||||
set => SetValue(SpacingProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SpacingProperty = DependencyProperty.Register(
|
||||
nameof(Spacing),
|
||||
typeof(double),
|
||||
typeof(HorizontalIconText),
|
||||
new PropertyMetadata(4d)
|
||||
);
|
||||
|
||||
|
||||
private static void OnOnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is HorizontalIconText view)
|
||||
{
|
||||
view.ShowIcon = view.Icon.IsNotBlank();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnPropertyChanged(e);
|
||||
if (e.Property == ShowSpaceProperty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShowSpace = ShowIcon && Text.IsNotBlank();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ internal static class ViewLifecycle
|
||||
if (ReferenceEquals(previous, next)) return;
|
||||
view.SetValue(LoadedViewModelProperty, next);
|
||||
previous?.OnUnloaded();
|
||||
next?.OnLoaded();
|
||||
next?.NotifyLoaded();
|
||||
}
|
||||
|
||||
private static void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -5,6 +5,20 @@ namespace Store.Management.Framework.Controls;
|
||||
|
||||
public abstract class ViewModelBase : BindableBase
|
||||
{
|
||||
private bool hasLoaded;
|
||||
|
||||
internal void NotifyLoaded()
|
||||
{
|
||||
if (!hasLoaded)
|
||||
{
|
||||
hasLoaded = true;
|
||||
OnLoadedOnce();
|
||||
}
|
||||
OnLoaded();
|
||||
}
|
||||
|
||||
/// <summary>当前实例首次加载时调用,先于 OnLoaded。</summary>
|
||||
protected virtual void OnLoadedOnce() { }
|
||||
protected internal virtual void OnLoaded() { }
|
||||
protected internal virtual void OnUnloaded() { }
|
||||
protected internal virtual void OnActivated() { }
|
||||
|
||||
Reference in new issue
Block a user