随笔分类 -  WPF

WPF
WPF如何设置Image.Source为资源图片
摘要:img.Source = new BitmapImage(new Uri(path,UriKind.RelativeOrAbsolute)); 阅读全文

posted @ 2019-01-24 19:06 范兵 阅读(1412) 评论(0) 推荐(0) 编辑

WPF异常“调用线程无法访问此对象,因为另一个线程拥有该对象 ”
摘要:WPF中在对界面进行操作的时候,可能会遇到“调用线程无法访问此对象,因为另一个线程拥有该对象”异常,这是因为WPF中只有UI线程才能操作UI元素,非UI线程要访问UI时就会报异常了。 解决方法: Dispatcher.BeginInvoke()与Invoke()方法。BeginInvoke()异步执 阅读全文

posted @ 2019-01-08 19:51 范兵 阅读(2679) 评论(0) 推荐(0) 编辑

WPF中得到一个控件相对其他控件的坐标
摘要:加入想得到按钮btnTest左上角相对于主窗体winTest的坐标,可以用如下方法:btnTest.TranslatePoint(new Point(0, 0), winTest)这个方法返回一个Point类型的值。 阅读全文

posted @ 2019-01-04 17:13 范兵 阅读(468) 评论(0) 推荐(0) 编辑

WPF中通过代码设置控件的坐标
摘要:Canvas.SetTop(myCanvas1, 0); Canvas.SetLeft(myCanvas1, 0); 阅读全文

posted @ 2018-12-28 20:48 范兵 阅读(2944) 评论(0) 推荐(0) 编辑

wpf 遍历控件及其值
摘要:private void SetNotEditable(UIElementCollection uiControls) { foreach (UIElement element in uiControls) { if (element is TextBox) { TextBox txtBox = ( 阅读全文

posted @ 2018-12-28 20:48 范兵 阅读(826) 评论(0) 推荐(0) 编辑

System.Windows.Freezable 在未被引用的程序集中定义
摘要:System.Windows.Freezable 在未被引用的程序集中定义 解决方法 添加windowsbase.dll 引用 阅读全文

posted @ 2018-12-28 20:47 范兵 阅读(573) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示