I liked this answer and it almost matched me.
But how can I achieve this if my DataTemplate
is in an external ResourceDictionary
?
I use Prism, and I provide DataTemplates
(for general CRUD views) by each module using these files:
<ResourceDictionary ... some hidden ns here ... > <DataTemplate DataType="{x:Type model:Operation}"> <vw:OperationView /> </DataTemplate> <DataTemplate DataType="{x:Type model:Customer}"> <vw:CustomerView /> </DataTemplate> </ResourceDictionary>
Then I use this answer to combine ResourceDictionaries
into a Shell application, and I have a default CRUD view that has this code:
<ContentControl Content="{Binding MyGenericObject}" />
In order for ContentControl
automatically display the correct view. It works fine, but I want to know to bind the property of objects in each view.
What is an example of these views (OperationView.xaml):
<UserControl x:Class="TryERP2.Cadastro.View.OperationView" ... some hidden NS ... > <StackPanel> <Label Content="Id" /> <TextBox Text="{Binding ????WHAT????}" /> <Label Content="Description" /> <TextBox Text="{Binding ????WHAT????}" /> </StackPanel> </UserControl>
How can I bind these properties?
source share