【自定义用户控件】CNMButton
使用方法
<!--可以独立使用-->
使用要点:
1、 必须在窗体的无参构造函数 初始化位置 添加 this.SizeChanged += cMNButton.SizeChanged_ChangedIcon;-
2、必须在窗体的无参构造函数 初始化位置 设置图标颜色(默认白色) cMNButton.MiniIcon.Fill = new SolidColorBrush(Color.FromRgb(255,255,255));
3、 必须在窗体的无参构造函数 初始化位置 可以设置和隐藏按钮 cMNButton.NomalWindowButton.Visibility = Visibility.Collapsed;
view
<Window x:Class="IndividualQAlibrary.MVVM.Views.AddQAView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:IndividualQAlibrary.MVVM.Views" xmlns:myb="clr-namespace:IndividualQAlibrary.Theme.Behaviors" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" xmlns:controls="clr-namespace:IndividualQAlibrary.Theme.Controls" mc:Ignorable="d" WindowStartupLocation="CenterScreen" Style="{DynamicResource QAViewStyle}" Title="NewQAView" Height="800" Width="1100"> <controls:CNMButton x:Name="cMNButton" Panel.ZIndex="10" Width="160" Grid.Row="0" Height="40" Grid.Column="1" HorizontalAlignment="Right" Grid.ColumnSpan="3" > </controls:CNMButton> </Window>
public partial class AddQAView : Window { public AddQAView() { InitializeComponent(); this.DataContext = new AddQAViewModel(); //根据窗体调整 按钮 this.SizeChanged += cMNButton.SizeChanged_ChangedIcon; //设置按钮的颜色 cMNButton.NomalIcon.Fill = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); cMNButton.CloseIcon.Fill = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); cMNButton.MiniIcon.Fill = new SolidColorBrush(Color.FromArgb(128,0,0,0));
//调整按钮的图标的大小
cMNButton.MinWindowButton.Padding = new Thickness(17, 14, 17, 14); } }
编程是个人爱好
分类:
WPF / wpf 控件
, WPF / 自定义控件
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· [翻译] 为什么 Tracebit 用 C# 开发
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· 2分钟学会 DeepSeek API,竟然比官方更好用!
· .NET 使用 DeepSeek R1 开发智能 AI 客户端
· 刚刚!百度搜索“换脑”引爆AI圈,正式接入DeepSeek R1满血版