WPF后台设置颜色字体等


Button TempButton = new Button();

                      
                        TempButton.Tag = “按钮标记”;
                        TempButton.Height = 30;
                        TempButton.Width = 100;
                        TempButton.Style = this.FindResource("ButtonStyle_blue") as Style;
                                   
                         //颜色
                        TempButton.Background = new SolidColorBrush(Colors.Black);//背景色
                        TempButton.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x6e, 0x6e, 0x6e));//前景色(字体颜色)
                        
                        //字体
                        TempButton.FontFamily = new FontFamily("Microsoft YaHei");
                        TempButton.FontSize = 13;
                        TempButton.FontWeight = FontWeights.Normal; 
                         
                         //布局
                        TempButton.Margin = new Thickness(0);      
                        TempButton.VerticalAlignment = VerticalAlignment.Center;
                        TempButton.HorizontalAlignment = HorizontalAlignment.Right;  
                        
                         //URL
                        (TempButton.Background as ImageBrush).ImageSource = new BitmapImage(new Uri(“图片路径”), UriKind.Absolute));
 
                        Wrappanel.Children.Add(TempButton);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM