c# - WPF Dynamic Data Binding in Image source -


what m doing wrong?

xaml:

<grid>     <grid.rowdefinitions>         <rowdefinition height="26*"/>         <rowdefinition height="63*"/>         <rowdefinition height="67*"/>     </grid.rowdefinitions>     <textblock name ="title" text="" textwrapping="nowrap" grid.row="0" margin="25,10,25,0"/>     <image source="{binding path=bindimgurl}" horizontalalignment="left" height="164" grid.row="1" verticalalignment="top" width="306" margin="152,0,0,0"/> </grid> 

c# code:

private string id;     private string imgurl;     public videodetails(string id)     {         initializecomponent();         this.id = id;         detailsgenerator dg = new detailsgenerator(id);         this.imgurl = "dynamic source";         this.datacontext = bindimgurl;         messagebox.show(bindimgurl);      }     public string bindimgurl     {         { return imgurl; }         set         { imgurl = value; }     } 

displaying source correct! checked messagebox.but no image did wrong? have tried removing "path=" doesn't worked

i imagine either want set datacontext this

this.datacontext = this; 

or change binding current datacontext

<image source="{binding}" .../> 

at moment image search bindimgurl in current datacontext, set bindimgurl , string

not related problem suggest implementing inotifypropertychanged , raising propertychanged event bindimgurl as, @ moment, after set datacontext change bindimgurl won't picked ui


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -