wpf - Is there an existing way to use arbitrary C# expressions in XAML? -


i'd able use arbitrary c# expressions in xaml. compute property ui element based on 2 bound values.

for example calculating width of ui element based on 2 other properties.

this contrived example of i'd xaml like:

<textbox    x:name="textbox1"    />  <textbox    x:name="textbox2"    />  <rectangle     height={double.parse(textbox1.text) + double.parse(textbox2.text)}     /> 

of course there no built-in way of doing in xaml.

i know use multibinding combined custom converter , way kind of thing. seems me simpler include c# code in xaml , wondering if out there had solved problem xaml extension or else.

you embed c# code xaml this:

 <x:code>             <![cdata[              void buttononclick(object sender, routedeventargs args)             {                 button btn = sender button;                 messagebox.show("the button labeled '" +                                 btn.content +                                 "' has been clicked.","information message");             }             ]]>   </x:code> 

but approach not recommended @ because mixes pure presentation layer business logic.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -