Question

I have a Wpf project in which i created a resource dictionary but i vant have access to my tamplates inside it.

Inside my dictionary i have this :

<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>

How can i use this in my MainWindow xaml ??

Was it helpful?

Solution

Inside your App.xaml paste this into <Application.Resources>:

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="YOUR DICTIONARY NAME.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top