使用方法
<!--可以獨立使用-->
使用要點:
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); } }