随笔分类 -  WPF

摘要:private DispatcherTimer _timer; private void SetTimeElaspInStatusBar() { try { _timer = new DispatcherTimer(); _timer.Tick += (sender, e) => { DateTime dtNow = DateTime.Now; ... 阅读全文
posted @ 2014-01-23 19:31 quietwalk 阅读(361) 评论(0) 推荐(0)
摘要:1)可以使绑定控件与基础数据源保持同步2)还可以在您添加、删除、移动、刷新或替换集合中的项目时引发 CollectionChanged 事件3)还可以在您的窗口以外的代码修改基础数据时做出反应4)相互转换T tList = new List(tObjectStruct .ToList()); ObservableCollection tObjectStruct = new ObservableCollection(tList); 都在构造函数中即可完成也可以:tList.ForEach(p => tObjectStruct.Add(t)); ObservableCollection类的. 阅读全文
posted @ 2014-01-23 19:09 quietwalk 阅读(1301) 评论(0) 推荐(0)
摘要:private void ruleListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListViewItem item = Utilities.GetVisualParent((UIElement)Mouse.DirectlyOver); if (item == null) return; Cdsrule rule = item.Content as Cdsrule; if (rule != null) ... 阅读全文
posted @ 2014-01-23 19:08 quietwalk 阅读(1193) 评论(0) 推荐(0)
摘要:1)根据名称查找 PrintPreview fe = new PrintPreview(new Summary()); string strResourceHeader = "headerStyle" + styleSize.ToString(); HeaderStyle = (Style)fe.FindResource(strResourceHeader);2)根据名称直接获取 Style baseStyle = this.Resources["gridRowStyle"] as Style; 阅读全文
posted @ 2014-01-23 19:06 quietwalk 阅读(350) 评论(0) 推荐(0)
摘要:OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "All Files (*.*)|*.*"; dialog.Multiselect = false; if (dialog.ShowDialog() == true) { txtKeyPath.Text = dialog.FileName; } 阅读全文
posted @ 2014-01-23 19:05 quietwalk 阅读(232) 评论(0) 推荐(0)
摘要:... 阅读全文
posted @ 2014-01-23 19:04 quietwalk 阅读(291) 评论(0) 推荐(0)
摘要:< > = <= >= <> 阅读全文
posted @ 2014-01-23 19:03 quietwalk 阅读(194) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2014-01-23 19:02 quietwalk 阅读(3841) 评论(0) 推荐(0)
摘要:1)由控件获取内容:ListViewItem item = Utilities.GetVisualParent(chx); if (item == null) return; ListView2.SelectedItems.Clear(); item.IsSelected = true; Outpatient outpatient = item.Content as Outpatient;2) Patientappointment appointment = ListView... 阅读全文
posted @ 2014-01-23 19:01 quietwalk 阅读(243) 评论(0) 推荐(0)
摘要:private void ListView1_MouseMove(object sender, MouseEventArgs e) { Patientappointment appointment = ListView1.SelectedItem as Patientappointment; if (appointment != null) { SelectedAppointment = appointment; if (e.LeftButton == ... 阅读全文
posted @ 2014-01-23 19:00 quietwalk 阅读(506) 评论(0) 推荐(0)
摘要:1.GetVisualParentpublic static T GetVisualParent(DependencyObject obj) where T : DependencyObject{DependencyObject parent = obj;while (true){if (parent == null) return null;T t = parent as T;if (t != null) return t;parent = VisualTreeHelper.GetParent(parent);}}使用示例代码: Button btn = sender as Button; 阅读全文
posted @ 2014-01-23 18:59 quietwalk 阅读(575) 评论(0) 推荐(0)
摘要:... 阅读全文
posted @ 2014-01-23 18:56 quietwalk 阅读(749) 评论(0) 推荐(0)
摘要:PickPatientReminderTableDialog dialog = new PickPatientReminderTableDialog(); dialog.Owner = Application.Current.Windows.Cast().SingleOrDefault(x => x.IsActive); 阅读全文
posted @ 2014-01-23 18:54 quietwalk 阅读(383) 评论(0) 推荐(0)
摘要:private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = sender as TextBox; TextChange[] change = new TextChange[e.Changes.Count]; e.Changes.CopyTo(change, 0); int offset = change[0].Offset; if (change[0... 阅读全文
posted @ 2014-01-23 18:53 quietwalk 阅读(641) 评论(0) 推荐(0)
摘要:1)不应当设置硬编码的高度,这样不能适应不同的字体大小,并且可能导致布局问题。2)可以使用方便的 MinLines和 MaxLines属性,设置在文本框中必须显示的最小行数。3)从代码中,可以检查 LineCount 属性准确地获取文本框中一共有多少行。4)在文本内容中移动:LineUp(); LineDown(); PageUp(); PageDown(); ScrollToHome();ScrollToEnd(); ScrollToLine 阅读全文
posted @ 2014-01-23 18:52 quietwalk 阅读(185) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2014-01-23 18:51 quietwalk 阅读(386) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2014-01-23 18:49 quietwalk 阅读(417) 评论(0) 推荐(0)
摘要:获取主窗口的引用:Window main=Application.Current.MainWindow获取程序中打开的所有窗口:Application.Currrent.Windows(在一个自定义应用程序类中保存那些需要用到的窗口的引用可能更有意义) 阅读全文
posted @ 2014-01-23 18:49 quietwalk 阅读(139) 评论(0) 推荐(0)
摘要:/// /// AsynchronousLoading class /// public static class AsynchronousLoading { /// /// AsyncInvokeHandler delegate /// /// object public delegate object AsyncInvokeHandler(); /// /// AsyncInvokeCallbackHandler /// ... 阅读全文
posted @ 2014-01-23 18:48 quietwalk 阅读(687) 评论(0) 推荐(0)
摘要:Step 1在WPF的C#代码文件中给定义复杂类型的变量,并给其赋值;Sample code: ListlsUser=。。。。Setp 2在 C#代码对应的XAML 中将此复杂参数定义为资源;Sample code: ...这里的命名空间 C 是你的复杂参数所在的命名空间;Step 3 Step 4 Converter 里对参数的使用public class UserNameConverter : IValueConverter { public object IValueConverter.Convert(object value, Type tar... 阅读全文
posted @ 2014-01-23 18:46 quietwalk 阅读(381) 评论(0) 推荐(0)