Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually instantiate a DataTemplate?

Is it possible to use a data template for a single item with no ListBox or other items control?

I have a datatemplate that I want to instantiate in xaml, not in a list, just within a border, and set its datacontext.

Something like (pseudo):

<Window DataContext="{StaticResource Contact}">
    <!--
        Here I want to show a ContactTemplate for a single Contact
        as it would appear in an ItemsControl (ListBox etc.)
    -->
    <src:ContactTemplate Source="{Binding}"/>
</Window>
like image 709
Shimmy Weitzhandler Avatar asked Sep 05 '09 19:09

Shimmy Weitzhandler


1 Answers

You can set the ContentTemplate of a ContentControl to a DataTemplate. Is that what you're looking for?

like image 160
Robert Rossney Avatar answered Oct 04 '22 00:10

Robert Rossney