WPF Note

1.xaml控件使能

 IsReadOnly ="True"只读 

 IsEnable ="False" 不可操作,变灰

 IsHitTestVisible="False" 不可操作,不变灰

2.控件:内容控件(Content Control),集合控件(ItemControl)

3.资源地址:pack://application:,,, 

pack://application:,,,/项目之下建的文件夹/UCFlowLeaveAndOverMain.xaml

4.RelayCommand类和DelegateCommand

RelayCommand自动更新,而DelegateCommand所做的操作需前段触发一下才可触发。

 5.cs代码中颜色的赋值

gd.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0));
gd.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#333333"));
gd.Background = new SolidColorBrush(Colors.Transparent);

如下这种直接在后台代码中写字符串White的注意运行时可能报错

System.Windows.Controls.Button b = new System.Windows.Controls.Button();
b.Content = "OK";
b.Background = (Brush)System.ComponentModel.TypeDescriptor.GetConverter(
typeof(Brush)).ConvertFromInvariantString("White");

6...NET FRAMWORK 的各个方法介绍

https://docs.microsoft.com/zh-cn/dotnet/api/system.linq.enumerable.groupby?view=netframework-4.7.2

7.Linq 自带的一些方法:Sql. (点出来)

items.Select(s=> new { Sql. }).ToList();

8.ObservableCollection 排序后:集合排序要NEW一下>>重新赋值才能生效

OcFlowStepConfigTemplate = new ObservableCollection<FlowCheckConfiguration>(OcFlowStepConfigTemplate.OrderBy(o => o.StepNo));

 9. 不带参数的数据刷新

 System.Windows.Application.Current.Dispatcher.Invoke(Init);

  带参的数据刷新
  Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
  {
    GetFlowTree(ret);
  }); //刷新数据

 10.GroupBy 用法

OcSheetNameInfo = OcFlowCheckTableNameConfig
.GroupBy(flowBase => flowBase.FunctionTableName)
.Select(S => new FlowCheckTableNameConfig { FunctionTableName = S.Key }).ToObservableCollection();

11【鼠标光标】

cs
this.Cursor = Cursors.Wait; 等待
xmal
Cursor="Help"

12.小尺寸文本不清晰时设置

TextOptions.TextFormattingMode="Display"

13.TextDecorations="BaseLine" 或“Strikethrough”“Underline”"OverLine"

14.获取电脑中的字体

foreach (FontFamily fontFamily in Fonts.SystemFontFamilies)
{
this.ListBox1.Items.Add(fontFamily.Source);
}

15.Calendar  支持多个日期: SelectionMode="SingleRange"

16.RadioButton使用时每组只能选一个通过相同的GroupName="togetherSign"设置


绑定数据时需注意
当两个RadioButton绑定一个Bool量,互相取反时使用了Converter就不要再设置GroupName,否则会造成无限循环而报错

<RadioButton Grid.Row="1" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center"
Content="单步" IsChecked="{Binding FlowSignStepSetting.IsTogetherSign}"/>
<RadioButton Grid.Row="2" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center"
Content="双步" IsChecked="{Binding FlowSignStepSetting.IsTogetherSign, Converter={StaticResource ReverseBoolConverter}}"/>

原文地址:https://www.cnblogs.com/mamaxiaoling/p/9831826.html