ValidationRule 验证时, 当验证失败后,再次验证成功, errorTemplate 还是触发, 不会被清掉. 因此需要主动调用 Validation.ClearInvalid(dtpTest.GetBindingExpression(DatePicker.TextProperty));…
原文:WPF中使用定时器的注意事项 注意事项 要使用System.Windows.Threading.DispatcherTimer,而不能使用System.Timers.Timer. 原因是WPF是单线程的图形操作. 使用方法 在构造上面有一些不同 _timer = new DispatcherTimer(); _timer.Interval = new TimeSpan(0, 0, 1); //间隔1秒 _timer.Tick += new EventHandler(TimeUp); _ti…
当wpf使用multibinding时, 其内部的validaterule的value 是其多个Binding的值, 要根据情况去验证, 还有就是在做IMultiConverter的ConvertBack时注意TargetType 如: 以下是一个Textbox通过MultiBinding绑定到后台 的字段, 以及前台的一个radiobutton, 该textbox有个validaterule.   <TextBox x:Name="txtPatientWeight" TextW…
wpf中有validateRule类, 用于界面元素的验证, 如何后台去控制validateRule呢? 1. UI层要binding写好的ValidateRule,分为Binding和MultiBinding, 如下面分别实现了Combobox的SelectedValuePropperty的Binding      和TextBox的TextProperty的MultiBinding.其中都有ValidationRule.        <ComboBox x:Name="cmbAgeT…
一.onNewIntent() 在IntentActivity中重写下列方法:onCreate onStart onRestart  onResume  onPause onStop onDestroy  onNewIntent 1.其他应用发Intent,执行下列方法:onCreateonStartonResume 发Intent的方法: Uri uri = Uri.parse("philn://blog.163.com"); Intent it = new Intent(Inten…
默认是当目标发生改变时候,通过绑定改变源时候进行校验,因为WPF认为源是安全的,如果想让源改变时候,也进行校验则设置验证规则的ValidatesOnTargetUpdated =true using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Con…
需求背景 需要显示 ViewModel 中的 Message/DpMessage,显示内容根据其某些属性来确定.代码结构抽象如下: // Model public class Message : INotifyPropertyChanged { public string MSG; public string Stack; } // ViewModel public class MessageViewModel : INotifyPropertyChanged { public Message…
1.普通控件重写需要添加一行 <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="{TemplateBinding Padding}"></ContentPresenter> 2.TextBox之类的编辑控件重写,需要填加一行 <ScrollViewer x:Name="PART_ContentH…
一.onNewIntent() 在IntentActivity中重写下列方法:onCreate onStart onRestart  onResume  onPause onStop onDestroy  onNewIntent 1.其他应用发Intent,执行下列方法: onCreate onStart onResume 发Intent的方法: 1 Uri uri = Uri.parse("philn://blog.163.com"); 2 Intent it = new Inten…
方法一使用mvvmlight: xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4" <i:Interaction.Triggers> <…