其他分享
首页 > 其他分享> > WPF学习日记10

WPF学习日记10

作者:互联网

1.expression as Type
解析:expression is Type ? (Type)expression : (Type)null

2.System.Windows.ResourceDictionary.MergedDictionaries()
解析:获取一套ResourceDictionary构成合并字典中的各种资源字典的字典。

3.System.Windows.Controls.ItemsControl
解析:表示用于呈现的项的集合的控件。

4.System.Windows.Controls.ItemsControl.ItemsPanel()
解析:获取或设置模板,该模板定义对项的布局进行控制的面板。

5.System.Windows.DynamicResourceExtension
解析:实现标记扩展支持动态资源引用XAML。

6.System.Windows.Controls.Border
解析:在另一个元素四周绘制边框和/或背景。

7.System.Windows.UIElement.Visibility()
解析:获取或设置此元素的用户界面[UI]可见性,这是依赖项属性。

8.System.Windows.Controls.Primitives.StatusBar
解析:表示应用程序窗口中的水平栏中显示项和信息的控件。

9.System.Windows.Controls.Border.BorderBrush()
解析:获取或设置用于绘制外部边框颜色的Brush。

10.System.Drawing.Brush
解析:定义用于填充图形形状[比如矩形、椭圆、饼形、多边形和封闭路径]的内部的对象。

11.System.Drawing.SolidBrush.SolidBrush(Color color)
解析:初始化指定颜色的新SolidBrush对象。

12.GalaSoft.MvvmLight.Threading.DispatcherHelper
解析:Helper class for dispatcher operations on the UI thread.

13.System.Windows.Controls.Primitives.Selector.SelectedIndex
解析:获取或设置当前所选内容或返回的第一项的索引为负一(-1)如果所选内容为空。

14.System.Configuration.ApplicationSettingsBase.Save()
解析:存储应用程序设置属性的当前值。

15.System.GC.Collect(int generation)
解析:强制对generation代到指定代进行即时垃圾回收。

16.GalaSoft.MvvmLight.CommandWpf.RelayCommand.RelayCommand(Action execute, bool keepTargetAlive = false)
解析:Initializes a new instance of the RelayCommand class that can always execute.

17.GalaSoft.MvvmLight.ICleanup
解析:Cleans up the instance, for example by saving its state, removing resources, etc.

18.GalaSoft.MvvmLight.ObservableObject
解析:A base class for objects of which the properties must be observable.

19.GalaSoft.MvvmLight.Messaging.IMessenger.Send<bool>(bool message, object token)
解析:Sends a message to registered recipients.

20.RelayCommand
解析:通过RelayCommand类的构造函数传入Action类型的Execute委托和Func类型的CanExecute委托,CanExecute委托用于表示当前命令是否可以执行,Execute委托则表示执行当前命令对应的方法。

public RelayCommand(Action execute, bool keepTargetAlive = false)
      : this(execute, (Func<bool>) null, keepTargetAlive)
{
}

21.ViewModelLocator类
解析:
[1]它被生成资源字典并加入到了全局资源,所以每次App初始化的时候,就会去初始化ViewModelLocator类。
[2]它是一个很基本的视图模型注入器,在构造器中把使用到的ViewModel统一注册,并生成单一实例。然后使用属性把它暴露出来,每当访问属性的时候,就会返回相应的ViewModel实例。
[3]自定义ViewModel的时候,可以在ViewModelLocator类的构造函数中对ViewModel进行注册,然后在该类中定义一个属性,用于返回自定义ViewModel。

22.ObservableObject类
解析:ObservableObject类位于GalaSoft.MvvmLight命名空间,实现INotifyPropertyChanged接口,通过触发PropertyChanged事件达到通知UI属性更改的目的。

23.Locator
解析:Key为Locator的类型为ViewModelLocator的资源在App.xaml中被声明,是一个全局资源。

<Application.Resources>
    <!--Global View Model Locator-->
    <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
</Application.Resources>

24.UpdateSourceTrigger取值
解析:

枚举类型说明
Default默认值[默认LostFocus]
Explicit当应用程序调用UpdateSource方法时生效
LostFocus失去焦点的时候触发
PropertyChanged属性改变时立即触发

25.Mode属性取值
解析:
[1]OneWay:源发生变化,数据就会从源流向目标
[2]OneTime:绑定会将数据从源发送到目标,但是仅当启动了应用程序或DataContext发生更改时才会如此操作,因此它不会侦听源中的更改通知。
[3]OneWayToSource:绑定会将数据从目标发送到源
[4]TwoWay:绑定会将源数据发送到目标,但如果目标属性的值发生变化,则会将它们发回给源
[5]Default:绑定的模式根据实际情况来定,如果是可编辑的就是TwoWay,只读的就是OneWay

参考文献:
[1]MVVMLight教程:https://www.cnblogs.com/3xiaolonglong/tag/MVVMLight/

标签:10,Windows,System,RelayCommand,GalaSoft,MvvmLight,WPF,解析,日记
来源: https://blog.csdn.net/shengshengwang/article/details/109139516