This is a migrated thread and some comments may be shown as answers.

How to do the dataTemplate Binding

1 Answer 156 Views
Book
This is a migrated thread and some comments may be shown as answers.
o
Top achievements
Rank 2
o asked on 15 Sep 2013, 12:24 PM
Hi,

I want to put the following RTB fir the LeftPage and rightPage for the book.

this is the Dictionary code where I created the Left and right pages for the book :

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Style x:Key="myStyle" TargetType="Button">
            <Setter Property="Background" Value="Orange" />
            <Setter Property="FontStyle" Value="Italic" />
            <Setter Property="Padding" Value="8,4" />
            <Setter Property="Margin" Value="4" />
        </Style>
     
 
        <!--  Declare the template used for the left pages  -->
        <DataTemplate x:Name ="LeftPageTemplate"   >
            <StackPanel Margin="10" Background="LightGray">
 
               
            </StackPanel>
        </DataTemplate>
        <!--  Declare the template used for the right pages  -->
        <DataTemplate x:Name="RightPageTemplate" DataType="Grid"  >
            <StackPanel Margin="10" Background="LightBlue">
                <TextBlock HorizontalAlignment="Right"
                           FontSize="24"
                           FontWeight="Bold"
                           Text="{Binding Title}" />
                <Image Width="240"
                       Height="320"
                       Source="{Binding Image}" />
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                    <TextBlock FontWeight="Bold" Text="Date Taken:" />
                    <TextBlock Text="{Binding DateTaken}" />
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                    <TextBlock FontWeight="Bold" Text="Size:" />
                    <TextBlock Text="{Binding Size}" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>
 
      
 
</ResourceDictionary>



The problem is, How do I create the Template, I tried the example in the Help Document and it still do not work.
 I get the following error,
'Could not register named object. Names not supported under ResourceDictionary scope.' Line number '12' and line position '23

Please see attached image.

Regards,
Omar



1 Answer, 1 is accepted

Sort by
0
o
Top achievements
Rank 2
answered on 15 Sep 2013, 03:27 PM
Hi,

I solved it by changing

<DataTemplate x:Name ="LeftPageTemplate"   >

To:

<DataTemplate x:Key ="LeftPageTemplate"   >


Tags
Book
Asked by
o
Top achievements
Rank 2
Answers by
o
Top achievements
Rank 2
Share this question
or