XAML:
- <ha:HSmartWindowControlWPF x:Name="hSmartWindowControlWPF" HKeepAspectRatio="True" HDoubleClickToFitContent="False" HMoveContent="{Binding MoveContent}"
- HZoomContent="{Binding ZoomContent, Converter={StaticResource zoomConverter}}" HMouseDown="ImageWindowEx_HMouseDown"
- MouseRightButtonDown="hSmartWindowControlWPF_MouseRightButtonDown">
- <ha:HIconicDisplayObjectWPF IconicObject="{Binding DisplayImage}" />
- <ha:HIconicDisplayObjectWPF IconicObject="{Binding DisplayIcon}" />
- <ha:HMessageDisplayObjectWPF HMessageText="{Binding DisplayText}" />
- </ha:HSmartWindowControlWPF>
复制代码
窗口类:
- this.DataContext = _model; // 初始化模型后再绑定给窗口的数据上下文
复制代码
模型(继承DependencyObject和INotifyPropertyChanged):
- /// <summary>
- /// 显示图像
- /// </summary>
- private HObject _DisplayImage;
- public HObject DisplayImage { get => _DisplayImage; set { _DisplayImage = value; OnPropertyChanged(); } }
- /// <summary>
- /// 显示区域
- /// </summary>
- private HObject _DisplayIcon;
- public HObject DisplayIcon { get => _DisplayIcon; set { _DisplayIcon = value; OnPropertyChanged(); } }
- /// <summary>
- /// 显示文字
- /// </summary>
- private string _DisplayText;
- public string DisplayText { get => _DisplayText; set { _DisplayText = value; OnPropertyChanged(); } }
复制代码
针对模型对象的DisplayImage操作就可以看到图像了。
|