wpf - Binding an image in a datatemplate -


i'm trying add menu application, i'd menu header connected user's picture.

my issue every binding works except 1 image, i've understood on net datatemplate use replace menu header picture doesn't have access it's parent datacontext. tried use stuff relative source , other tricks no luck (certainely related fact i'm new in mvvm , still have lot learn :) )

here's code i'm using :

<grid datacontext="{binding user}">     <dockpanel>         <label content="{binding strings.hello, source={staticresource stringlocalizer} }" verticalalignment="center" padding="0,0,5,0" fontfamily="{dynamicresource font_normal}" fontsize="15" foreground="white"/>         <textblock text="{binding displayname, targetnullvalue='guest', fallbackvalue='guest'}" verticalalignment="center" horizontalalignment="left" fontfamily="{dynamicresource font_normal}" fontsize="15" foreground="white"/>           <menu name="logonmenu" margin="10,0,0,0" datacontext="{binding user}">             <menuitem >                 <menuitem.headertemplate>                     <datatemplate>                         <!--<image source="{binding datacontext.image,relativesource={relativesource findancestor, ancestortype={x:type application}}, converter={staticresource imageconverter}, fallbackvalue={staticresource defaultusericon}}"/>-->                         <image datacontext="{binding user}" source="{binding path=image, converter={staticresource imageconverter}, fallbackvalue={staticresource defaultusericon},mode=twoway}"/>                     </datatemplate>                 </menuitem.headertemplate>                  <menuitem header="{binding strings.signin, source={staticresource stringlocalizer}}" width="150" margin="10,0,0,0" isenabled="{binding connected, converter={staticresource boolinverterconverter}}" visibility="{binding relativesource={relativesource mode=self},path=isenabled, converter={staticresource booltovisibilityconverter}}" command="{binding relativesource={relativesource ancestortype=window},path=datacontext.signincommand}"/>                 <menuitem header="{binding strings.signout, source={staticresource stringlocalizer}}" margin="10,0,0,0" isenabled="{binding connected}" visibility="{binding relativesource={relativesource mode=self},path=isenabled, converter={staticresource booltovisibilityconverter}}" command="{binding relativesource={relativesource ancestortype=window},path=datacontext.signoutcommand}"/>                 <menuitem header="{binding strings.userinformation, source={staticresource stringlocalizer}}" margin="10,0,0,0" isenabled="{binding connected}" visibility="{binding relativesource={relativesource mode=self},path=isenabled, converter={staticresource booltovisibilityconverter}}"/>             </menuitem>         </menu>     </dockpanel> </grid> 

in case image shows fallback picture, if me finding way have user's picture great.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo