tags:

views:

41

answers:

1

I could use FrameworkElementFactory to create a template, but this class is deprecated. The recommended way, according to MSDN is to use XamlReader.Load to load XAML from a string or a memory stream. I get this to work, but think this is kind of sad:

string xaml = "a lot of XAML";

Any suggestions to be able to do this in a better way?

What I really want to do is be able to dynamically change a Binding path in a DataTemplate.

<DataTemplate x:Key="DataTemplate1">
    <StackPanel>
        <TextBlock>Some text</TextBlock>
        <TextBlock Text="{Binding ThePathIWantToChange}"/>
    </StackPanel>
</DataTemplate>
A: 

Jostein,

Wouldn't it be easier to change the property value and rise PropertyChanged event? Approach with updating whole data template looks like overkill for me.

Anvaka
I'm using the DataGrid from the WPFToolkit, but don't know what or how many columns I have at compile time. I use the AutoGeneratingColumn event of the DataGrid to set different column types based on some info in a business object. In some cases I need to use the DataGridTemplateColumn, and thus set the CellEditingTemplate and CellTemplate. When I set theese templates I would like the binding to be set to the current PropertyName given by the DataGridAutoGeneratingColumnEventArgs object. I'm not sure how I could apply your approach in this case?
Jostein