I have a GridView where I can generate the Columns at run time based upon the configuration settings. e.g Text Column = to show the text in it Image Column = to display the graphic in there.
but the problem is that the whole column would be shown either of them type. What I want to do is based upon the data of particular cell, I want (a) choose a dynamic template (b) render the contents dynamically (ideally) as FrameworkElement and set the cell content with that.
This means that the each cell can either display text or image. so in first row, 1st column could be text and 2nd row, 1st column could be graphics based upon the data value.
Is there a way to choose the template based upon run time content value of particular cell or completely render a UIElement and then set as value of the cell?
Example:-
Cell data = <bold>Hello. I'm bold</bold>
=> displays the text as bold (TextBlock Element)
Cell data = <img>test.png</img>
=> displays the graphic (Image Element)
You can achieve this with
Triggers
Here is the sample code. .
And the sample backend code