c# - Bind Rect Width and Height in xaml -


i trying bind width , height of rect in viewport this:

<visualbrush.viewport>     <rect width="{binding path=mywidth}" height="{binding path=myheight}"/> </visualbrush.viewport> 

my binding works fine elsewhere here following error message:

a 'binding' cannot set on 'width' property of type 'rect'. 'binding' can set on dependencyproperty of dependencyobject.

edit understand error message. question how work around it. how bind height , width of rect?

use multibinding this:

<visualbrush.viewport>     <multibinding>         <multibinding.converter>             <local:rectconverter/>         </multibinding.converter>         <binding path="mywidth"/>         <binding path="myheight"/>     </multibinding> </visualbrush.viewport> 

with multi-value converter this:

public class rectconverter : imultivalueconverter {     public object convert(object[] values, type targettype, object parameter, cultureinfo culture)     {         return new rect(0d, 0d, (double)values[0], (double)values[1]);     }      public object[] convertback(object value, type[] targettypes, object parameter, cultureinfo culture)     {         throw new notsupportedexception();     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -