随笔分类 -  WPF

摘要:先看效果 我修改了ToggleButton的ControlTemplate,在ContentPresenter外面加了4个Border,控制4个Border的位置在ControlTemplate的左上、右上、左下、右下,选中时,触发4个边框的BorderThickness <Setter Prope 阅读全文
posted @ 2024-09-26 14:56 liuyong111 阅读(691) 评论(0) 推荐(0)
摘要:先看效果 <Style TargetType="{x:Type ToggleButton}"> <Setter Property="Background" Value="Transparent"/> <Setter Property="BorderBrush" Value="DarkGray"/> 阅读全文
posted @ 2024-09-25 16:19 liuyong111 阅读(184) 评论(0) 推荐(0)
摘要:项目中用到了MaterialDesignTheme,他只有两种主题,light和dark。 查看源码,将他dark主题copy到我们项目中 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presenta 阅读全文
posted @ 2021-05-17 10:49 liuyong111 阅读(4118) 评论(0) 推荐(0)
摘要:效果图: 添加扩展类 public static class DataGridExtend { /// <summary> /// 获取DataGrid控件单元格 /// </summary> /// <param name="dataGrid">DataGrid控件</param> /// <pa 阅读全文
posted @ 2020-11-18 13:58 liuyong111 阅读(2360) 评论(0) 推荐(0)
摘要:vs2019更新到16.8.0 安装.net 5 sdk 下载地址 https://dotnet.microsoft.com/download/dotnet/5.0 安装完成后,打开PowerShell,进入希望生成的wpf项目文件夹。 例: 然后再输入dotnet new wpf -o Net5W 阅读全文
posted @ 2020-11-12 16:38 liuyong111 阅读(2681) 评论(1) 推荐(0)
摘要:ListView有时加载个几百条数据都要好几秒钟。 1.ItemsPanelTemplate中用的StackPanel,改成VirtualizingStackPanel。 <ListView ItemsSource="{Binding WOList}" > <ListView.ItemsPanel> 阅读全文
posted @ 2020-08-24 16:58 liuyong111 阅读(1772) 评论(0) 推荐(1)
摘要:在触摸屏上操作,用户尽可能的操作越简单,步骤越少越好。比如单据保存成功后,不用弹出保存成功的提示框,用户点确定后再关闭。这样增加了用户的操作。 var _notifyIcon = new NotifyIcon { BalloonTipText = @"保存成功!", Text = @"Hello, 阅读全文
posted @ 2020-04-24 16:35 liuyong111 阅读(810) 评论(0) 推荐(0)
摘要:public class TextBoxExtHelper { public static string GetIsNullString(DependencyObject obj) { return (string)obj.GetValue(IsNullStringProperty); } publ 阅读全文
posted @ 2020-04-24 13:41 liuyong111 阅读(459) 评论(0) 推荐(0)
摘要:MarkupExtension 标记扩展。wpf中已实现了很多MarkupExtension。如binding,x:StaticResource等等。通过继承MarkupExtension,我们可以自定义标记。 public class ColorExtend : MarkupExtension { 阅读全文
posted @ 2020-04-22 15:57 liuyong111 阅读(545) 评论(0) 推荐(0)
摘要:public class DecimalConverter:IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInf 阅读全文
posted @ 2020-03-16 16:30 liuyong111 阅读(2000) 评论(2) 推荐(0)
摘要:WPF程序捕获全局异常,遇到未处理的异常,虽可以捕获,但是不能阻止程序退出。 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledExcepti 阅读全文
posted @ 2019-12-31 14:46 liuyong111 阅读(946) 评论(0) 推荐(0)
摘要:一般我们WPF中都加全局捕获,避免出现异常导致崩溃。 Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; AppDomain.CurrentDomain.Unhandled 阅读全文
posted @ 2019-11-14 17:07 liuyong111 阅读(2340) 评论(0) 推荐(2)
摘要: 阅读全文
posted @ 2019-07-29 14:50 liuyong111 阅读(294) 评论(0) 推荐(0)
摘要:上面的是datagrid第一列的单元格背景色根据值改变。 阅读全文
posted @ 2019-07-15 18:47 liuyong111 阅读(2043) 评论(5) 推荐(0)
摘要:功能类似dev的layoutcontrol,layoutgroup,layoutitem. 用法如下: 不管label字段有多长,KDLayoutControl会设置容器内所有的label长度一致。 阅读全文
posted @ 2019-07-02 17:21 liuyong111 阅读(1143) 评论(2) 推荐(0)
摘要:之前使用的dev的gridcontrol,如果我的列bingding的字段与itemssource中的相同,而此列的Visibility设置为不可见,则界面显示的时候,这列就不可见。 但是用的DataGrid不支持这种功能,如果ItemsSource中也有IsHasExpend、FID、Parien 阅读全文
posted @ 2019-05-11 09:34 liuyong111 阅读(2709) 评论(1) 推荐(1)
摘要:权限控制我们有很多种方式可以实现。 这次项目中做个简单的权限控制,我们在所有按钮触发前判断,有权限则可执行。 我们自定义一个命令类。 在Execute时验证权限 用的时候将此按钮的权限对象传入Command 阅读全文
posted @ 2019-04-16 17:07 liuyong111 阅读(1703) 评论(0) 推荐(0)
摘要:CompositionTarget 是一个类,表示其绘制你的应用程序的显示图面。 WPF 动画引擎提供了许多用于创建基于帧的动画的功能。 但是,有应用程序方案中,您需要通过基于每个帧来呈现控件。 CompositionTarget对象提供了创建基于每帧回调的自定义动画的功能。 每帧渲染之前触发Com 阅读全文
posted @ 2019-03-14 18:30 liuyong111 阅读(1091) 评论(0) 推荐(0)
摘要:今天有个需求是需要拖拽DataGrid中的item到另一个DataGrid。自己实现还比较繁琐,网上查了查,发现一个不错的开源项目 gong-wpf-dragdrop nuget安装下:Install-Package gong-wpf-dragdrop -Version 1.1.0 在xaml中添加 阅读全文
posted @ 2019-03-04 15:03 liuyong111 阅读(1381) 评论(0) 推荐(0)
摘要:触摸屏上客户要求滚动条宽度大些,方便手指上下滚动,之前在网上看了个,原文找不到了,代码记录下。 效果如下: <ControlTemplate x:Key="ScrollViewerControlTemplate1" TargetType="{x:Type ScrollViewer}"> <Grid 阅读全文
posted @ 2019-02-14 15:19 liuyong111 阅读(1612) 评论(0) 推荐(0)