(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .
        Login with Facebook

Tip: How to use Path when binding?

(0 votes)
Denislav Savkov
>
Denislav Savkov
Joined Feb 11, 2008
Articles:   14
Comments:   6
More Articles
3 comments   /   posted on Aug 29, 2008
Categories:   Data Binding


Path is used to specify then name of the property of the underlying object to bind to. Additional you are able to use indirect property targeting to specify a sub-property of a property of the object. Currently it is not possible to bind to indexed properties.

Xaml

<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Path=Name}"/>
<TextBlock Text="{Binding Path=Account.OpenDate}"/>
<TextBlock Text="{Binding Path=Property1.Property2.Property3}"/>

That's it!


Subscribe

Comments

  • -_-

    RE: Tip: How to use Path when binding?


    posted by ED on Dec 16, 2008 12:35

    Can you bind to an indexed property (e.g. Path=Name[0])?

  • -_-

    RE: Tip: How to use Path when binding?


    posted by Animesh on Jan 08, 2009 15:28

    Yes u can...

  • MarceloRibeiro

    Re: Tip: How to use Path when binding?


    posted by MarceloRibeiro on Sep 11, 2011 22:17

    Can you bind to a property from a previous datacontext? E.g.

    <Grid DataContext={Binding Person}>
    <Grid DataContext={Binding Address}>
    <TexBox DataContext={Binding XXXX}>
    </Grid >
    </Grid>

    I wish thata XXXX where for example the Person.Name property. I have a very simmilar situation here, and i can't figure out how to do that.

    Thanks

Add Comment

Login to comment:
  *      *       
Login with Facebook