Shimmy Weitzhandler
Shimmy Weitzhandler

Reputation: 104821

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>

Upvotes: 5

Views: 1627

Answers (1)

Robert Rossney
Robert Rossney

Reputation: 96900

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

Upvotes: 9

Related Questions