1
我需要重新使用現有數據模板,定義爲reource,在控制嵌套數據模板
定義的數據模板......這是我的客戶數據模板作爲一種資源,因此它可以是一個可重複使用對象
顧客的DataTemplate:
<ResourceDictionary ... >
<DataTemplate DataType="{x:Type Model:Customer}">
<StackPanel Orientation="Vertical" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="140" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<TextBox Text="{Binding CustomerName}"
Grid.Column="0" Grid.Row="0" />
</StackPanel>
</DataTemplate>
</ResourceDictionary>
現在我需要重用在用戶控制數據模板
<UserControl x:Class="MyCustomerControl"
<UserControl.Resources >
<DataTemplate DataType="{x:Type frnri:CustomerViewModel}">
question: How can I reuse customer data template here?
</DataTemplate>
</UserControl.Resources>
</UserControl>
上面定義的客戶數據模板
是否可能這種情況沒有在MyCustomerControl中內聯定義客戶數據模板?
工作,我在App.xaml中客戶的DataTemplate ...但問題是,我需要一個datatemplate而不是我的控制列表框(tabcontrol顯示eterogdeous類型)感謝回覆 – guton
我認爲是UserControls的用途 – jimmyjambles