wpf 静态属性的绑定

  • Post author:
  • Post category:其他


xmal:

   <UserControl.Resources>
        <Global:GlobalPara x:Key="GlobalPara"></Global:GlobalPara>
    </UserControl.Resources>
 <ItemsControl ItemsSource="{Binding Source={StaticResource GlobalPara},Path=属性名称}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

cs

 private static ObservableCollection<WarehouseRuntime> warehouseRuntime = new ObservableCollection<WarehouseRuntime>();
        /// <summary>
        /// 运行时的仓库数据
        /// </summary>
        public static ObservableCollection<WarehouseRuntime> WarehouseRuntime
        {
            get => warehouseRuntime; set
            {
                warehouseRuntime = WarehouseRuntime;
                //调用通知
                StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(nameof(WarehouseRuntime)));
            }
        }
        /// <summary>
        /// 新建静态属性变更通知
        /// </summary>
        public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;



版权声明:本文为weixin_41440306原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。