Wpf “代码”的背后是什么;{StaticResource{dxgt:GridRowThemeKey ResourceKey=RowStyle}}";
这是我的XAML代码Wpf “代码”的背后是什么;{StaticResource{dxgt:GridRowThemeKey ResourceKey=RowStyle}}";,wpf,styles,settext,staticresource,Wpf,Styles,Settext,Staticresource,这是我的XAML代码 <Window x:Class="Q316995.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xa
<Window x:Class="Q316995.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
xmlns:local="clr-namespace:Q316995"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary>
<Style x:Key="LastRowHighlighted"
BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}"
TargetType="{x:Type dxg:GridRowContent}">
</Style>
</ResourceDictionary>
</Window.Resources>
</Window>
我不知道我该怎么替换
BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}"
用c代码。Grid是Devexpress的GridControl,
样式
类有一个构造函数,它接受一个样式
对象,以新的样式
为基础。您还可以根据找到的设置Style.BasedOn
属性
您可以使用以下命令从应用程序的资源部分访问默认样式集
:
Application.Current.TryFindResource(typeof(GridRowContent));
Style style = new Style(typeof(GridRowContent), Application.Current.TryFindResource(
typeof(GridRowContent)));
因此,请尝试以下方法:
Application.Current.TryFindResource(typeof(GridRowContent));
Style style = new Style(typeof(GridRowContent), Application.Current.TryFindResource(
typeof(GridRowContent)));
它正在引发错误{“'GridRowContent'TargetType与元素'TableView'的类型不匹配”。}。