我有一个 Wpf 项目,我在其中创建了一个资源字典,但我可以访问其中的模板。
在我的字典里,我有这个:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="Itemaki">
<StackPanel>
<Grid Background="#4C747474">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="C:\image.jpg" Stretch="Fill"/>
<Grid Grid.Column="1" Width="90" Margin="0,0,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding SName}" FontSize="13" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Grid.Row="1" Text="{Binding SGenre}" FontSize="9" Foreground="#FF2AACAC" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding SCountry}" FontSize="9" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Grid.Column="1" Text="{Binding SCity}" FontSize="9" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</Grid>
</StackPanel>
</DataTemplate>
我如何在我的 MainWindow xaml 中使用它?