代码拉取完成,页面将自动刷新
/*
*Description: PropertyGridDemoViewModel
*Author: Chance.zheng
*Creat Time: 2023/8/21 16:29:58
*.Net Version: 6.0
*CLR Version: 4.0.30319.42000
*Copyright © CookCSharp 2023 All Rights Reserved.
*/
using AutoMapper;
using CookPopularToolkit;
using CookPopularUI.WPFDemo.Models;
using Prism.Commands;
using System.Windows.Media.Imaging;
namespace CookPopularUI.WPFDemo.ViewModels
{
public class PropertyGridDemoViewModel : ViewModelBase
{
private IMapper _mapper;
private int index = 1;
public PropertyGridDemoModel DemoModel { get; set; }
public DelegateCommand UpdateCommand => new Lazy<DelegateCommand>(() => new DelegateCommand(OnUpdate)).Value;
public PropertyGridDemoViewModel()
{
var profile = new MappingProfile();
var configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile));
_mapper = configuration.CreateMapper();
DemoModel = TypeHelper.SetPropertiesDefaultValue<PropertyGridDemoModel>();
DemoModel.Lists = new List<string>() { "Chance1", "Chance2", "Chance3" };
DemoModel.ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/CookPopularUI.WPFDemo;component/Assets/Media/tomcat.png", UriKind.Absolute));
}
private void OnUpdate()
{
DemoModel.EditableString = $"数据第{index++}次更新了";
DemoModel.ReadOnlyString = "不可编辑文本";
//DemoModel = _mapper.Map<PropertyGridDemoModel>(DemoModel);
}
private void OnDemoModelChanged()
{
System.Diagnostics.Debug.WriteLine("对象DemoModel变化了");
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。