WPF - Display single entity with a data template
Asked Answered
O

1

20

I Have a data template that i use in items control, i wanna know if its possible some how to use it(the template) on single item display without the items control?

if not whats the best way to do it...?

Osber answered 16/4, 2009 at 8:6 Comment(0)
O
37

You can probably do something like this

**<DataTemplate x:Key="MyTemplate" DataType="{x:Type MyType}">**
    ...
**</DataTemplate>**
...
<ContentControl ContentTemplate="{StaticResource MyTemplate}" /> <!-- Single instance use -->
<ItemsControl ItemTemplate="{StaticResource MyTemplate}" /> <!-- Multiple instance use -->
Onieonion answered 16/4, 2009 at 8:9 Comment(2)
ContentControl Template property expects a ControlTemplate, not a DataTemplateSoni
ok.. kewl.. fixed my answer as well.. +1 for your quick edit :)Soni

© 2022 - 2024 — McMap. All rights reserved.