WPF 动态添加带样式按钮
2020-12-29 03:27
标签:nts alt xmlns horizon ref schema nes height targe 1.添加字典 2.App.Xmal中添加创建的字典 3.动态添加按钮的方法 private void GetUiElement_F() //BitmapFrame temp = BitmapFrame.Create(streamInfo.Stream); 4.效果图 WPF 动态添加带样式按钮 标签:nts alt xmlns horizon ref schema nes height targe 原文地址:https://www.cnblogs.com/gkxg/p/13299540.html
xmlns:local="clr-namespace:GenerateLogo"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Fill="#A7FF0000"
StrokeThickness="3">
Point1="75.860,47.685"
Point2="69.111,45.196"
Point3="50.167,45.196"/>
Point1="7.469,52.580"
Point2="1.000,53.252"
Point3="1.000,44.999"/>
Point1="9.106,14.370"
Point2="27.875,0"
Point3="50,0"/>
Point1="99.139,39.369"
Point2="98.999,40.084"
Point3="98.999,45.499"/>
CenterY="0.5"
ScaleX="1"
ScaleY="1.997"/>
CenterY="0.5"
ScaleX="1.5"
ScaleY="1.5"/>
CenterY="0.5"
ScaleX="1"
ScaleY="1.997"/>
CenterY="0.5"
ScaleX="1.5"
ScaleY="1.5"/>
CenterY="0.5"
ScaleX="1"
ScaleY="1.997"/>
{
//Uri resourceUri = new Uri("Images/logo.png", UriKind.Relative);
//StreamResourceInfo streamInfo = Application.GetResourceStream(resourceUri);
//var brush = new ImageBrush();
//brush.ImageSource = temp;
var tb = new Button
{
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
FontSize = 11,
FontWeight = FontWeights.Bold,
Foreground = Brushes.Transparent,
Width = 100,
Height = 100,
Margin = new Thickness(10),
};
// logo.RegisterName("btn1", tb);
tb.SetResourceReference(StyleProperty, "GlassYButton");
// tb.Background = brush;
tb.Click += new RoutedEventHandler(btnEvent_Click);
logo.Children.Add(tb);
}