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