gpt4 book ai didi

wpf - 如何以编程方式设置样式

转载 作者:行者123 更新时间:2023-12-03 07:23:32 25 4
gpt4 key购买 nike

我有以下样式,但我需要以编程方式制作它:

<xcdg:DataGridControl MinHeight="300" 
Name="listViewUnallocated"
ItemsSource="{Binding Source={StaticResource
cvs_unallocatedTerminals}}"
AllowDrop="True"
Drop="Grid_Drop"
MouseMove="Grid_MouseMove"
KeyUp="listViewUnallocated_KeyUp"
MouseDoubleClick="gridUnallocated_MouseDoubleClick"
ReadOnly="True"
DockPanel.Dock="Top">
<xcdg:DataGridControl.Resources>
<Style TargetType="{x:Type xcdg:DataRow}" x:Name="selectedStyleTrigger">
<Style.Triggers>
<DataTrigger Binding="{Binding TerminalId}" Value="72948028">
<Setter Property="Background" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</xcdg:DataGridControl.Resources>

最佳答案

在控件的代码隐藏文件中,尝试:

this.Style = Resources["ResourceName"] as Style;

关于wpf - 如何以编程方式设置样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3199424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com