我有扩展DataGrid
的自定义控件。它被称为ExtendedDataGrid
。我想为ExtendedDataGrid
提供与DataGrid
s样式相同的样式,但它会更改模板。我试过这样的事情:如何基于默认的DataGrid风格创建样式?
<Style TargetType="{x:Type MyControls:ExtendedDataGrid}" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="Template">
...
</Setter>
</Style>
但它说没有找到资源。
所以我尝试:
<Style TargetType="{x:Type MyControls:ExtendedDataGrid}" BasedOn="{StaticResource {ComponentResourceKey ResourceId=DataGridStyle, TypeInTargetAssembly={x:Type DataGrid}}}">
<Setter Property="Template">
...
</Setter>
</Style>
但它也不起作用......所以,我该怎么办?
是的,它的确解决了问题,请参阅我上面的回答:) – drasto 2011-02-13 18:27:41
想知道如果不是这样,那么因为你注意到它可以工作。 – 2011-02-13 18:30:52