Ras*_*sto 26 c# wpf datagrid styles
我有扩展的自定义控件DataGrid.它被称为ExtendedDataGrid.我希望为它提供样式ExtendedDataGrid与DataGrids样式相同,除非它更改模板.我尝试过这样的事情:
<Style TargetType="{x:Type MyControls:ExtendedDataGrid}" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="Template">
...
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
但它说没有找到资源.
所以我尝试:
<Style TargetType="{x:Type MyControls:ExtendedDataGrid}" BasedOn="{StaticResource {ComponentResourceKey ResourceId=DataGridStyle, TypeInTargetAssembly={x:Type DataGrid}}}">
<Setter Property="Template">
...
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
但它也行不通......那我该怎么办?
Ras*_*sto 50
好神秘解决了:)
我上面的第一个代码确实有效:
<Style TargetType="{x:Type MyControls:ExtendedDataGrid}" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="Template">
...
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我认为它不起作用因为VS(或Resharper)在我的代码中显示错误,说没有找到资源... VS(或Resharper)中的Bug :(
| 归档时间: |
|
| 查看次数: |
21002 次 |
| 最近记录: |