我有擴展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