wpf中动态更改控件或元素的样式

 if (Config.GridStyle == 1)
            {
                tableView2.RowStyle = this.Resources["RowStyle"] as Style;
                tableView2.CellStyle = this.Resources["customCellStyle"] as Style;
            }
            else if (Config.GridStyle == 2)
            {
                tableView2.RowStyle = this.Resources["RowStyle2"] as Style;
                tableView2.CellStyle = this.Resources["customCellStyle2"] as Style;
            }

 

 

 在资源文件中,定义了 上边调用的两个样式:


 
     

你可能感兴趣的:(wpf)