A window loads some dynamic Xaml which gets transformed with Xslt to display some content from a data source. Because the Xaml is dynamic, I cannot bind events until after it's loaded - the binding itself is okay, but I'm struggling to find a way to describe the event data in the source Xaml.
Let's say my source is as follows:
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<xsl:variable name="myValue" select="/root/System/CustomerFirstName"/>
<Label ##MyClick="method='myMethod', aParameter='$myValue', anotherParameter='test'"##>
<xsl:value-of select="/root/System/CustomerFirstName" />
</Label>
</Grid>
The code puts it through the Xslt processor which works perfectly if the bit between the ## is removed. I understand why it doesn't like the MyClick attribute as it's not defined. I have tried adding an attached property but the Xslt parser doesn't seem to know about it (maybe I'm missing a hookup). I've tried adding an extension object but the Xslt parser wants to call the method as it parses, instead of me handling that bit when a user clicks on the UI element.
What I want is the Xslt parser to preprocess but leave in my custom tag, such that any content is processed:
<Label MyClick="method='myMethod', aParameter='Geoff', anotherParameter='test'"> [etc]
The actual syntax of the inner text of MyClick is not important, as long as once the Xslt completes, I can walk the generated Xaml to find any nodes with MyClick defined and do my own processing on the content - in this case binding a Click event handler and then doing something with the parameters passed.
Another way, perhaps, is instead of attributes defining my custom behaviour, it is instead subelements inside the Label element. I can work with either, such as:
<Label><MyClick><Method>wibble</Method><Parameter Name="name" Value="{$myValue}"></Parameter></MyClick></Label>
...kind of thing
Ideas much appreciated.