954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

WPF data template

<Window.Resources>
...
...
        <DataTemplate DataType="{x:Type my:Section}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Name}"/>
                <TextBlock Text="  "/>
                <TextBlock Text="{Binding Path=Instructor}"/>
                <TextBlock Text="  "/>
                <TextBlock Text="{Binding Path=Cours}"/>
            </StackPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type my:Instructor}" x:Key="InstructorDataTemp">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=FirstName}"/>
                <TextBlock Text=" "/>
                <TextBlock Text="{Binding Path=LastName}"/>
            </StackPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type my:Cours}" x:Key="CourseDataTemp">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Name}"/>
            </StackPanel>
        </DataTemplate>
...
...
</Window.Resources>


I am using the section template right now. The section template correctly displays the Section's Name, but the Instructor and Cours both show up as basic toStrings. I would like them to show up as defined in the other data templates. Any help is appreciated

Thanks

white feather
Light Poster
49 posts since Apr 2010
Reputation Points: 18
Solved Threads: 2
 

I solved it by using an IValueConverter for the instructor (in the section) and in the binding for the cours (in the section) just saying Cours.Name

white feather
Light Poster
49 posts since Apr 2010
Reputation Points: 18
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: