packages/MaterialDesignThemes.2.5.1/src/net45/ListSortDirectionIndicator.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace MaterialDesignThemes.Wpf
{
    [TemplateVisualState(GroupName = DirectionGroupName, Name = NoneStateName)]
    [TemplateVisualState(GroupName = DirectionGroupName, Name = AscendingStateName)]
    [TemplateVisualState(GroupName = DirectionGroupName, Name = DescendingStateName)]
    public class ListSortDirectionIndicator : Control
    {
        public const string DirectionGroupName = "Direction";
        public const string NoneStateName = "None";
        public const string AscendingStateName = "Ascending";
        public const string DescendingStateName = "Descending";        

        static ListSortDirectionIndicator()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ListSortDirectionIndicator), new FrameworkPropertyMetadata(typeof(ListSortDirectionIndicator)));
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            GotoVisualState(true, ListSortDirection);
        }


        public static readonly DependencyProperty ListSortDirectionProperty = DependencyProperty.Register(
            nameof(ListSortDirection), typeof (ListSortDirection?), typeof (ListSortDirectionIndicator), new PropertyMetadata(default(ListSortDirection?), ListSortDirectionPropertyChangedCallback));

        private static void ListSortDirectionPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            var indicator = (ListSortDirectionIndicator) dependencyObject;
            indicator.GotoVisualState(true, indicator.ListSortDirection);
            indicator.IsNeutral = !indicator.ListSortDirection.HasValue;
        }

        public ListSortDirection? ListSortDirection
        {
            get { return (ListSortDirection?) GetValue(ListSortDirectionProperty); }
            set { SetValue(ListSortDirectionProperty, value); }
        }

        private static readonly DependencyPropertyKey IsNeutralPropertyKey =
            DependencyProperty.RegisterReadOnly(
                "IsNeutral", typeof (bool), typeof (ListSortDirectionIndicator),
                new PropertyMetadata(true));

        public static readonly DependencyProperty IsNeutralProperty =
            IsNeutralPropertyKey.DependencyProperty;

        public bool IsNeutral
        {
            get { return (bool) GetValue(IsNeutralProperty); }
            private set { SetValue(IsNeutralPropertyKey, value); }
        }

        private void GotoVisualState(bool useTransitions, ListSortDirection? direction)
后面还有 11 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。