How to expose elements inside templates so that it can be manipulated at runtime


i creating template follow

 

<controltemplate x:key="pintemplate" targettype="m:pushpin" > 
 
<grid> 
 
<!--<ellipse fill="red" width="50" height="100" />-->
<
image height="auto" horizontalalignment="left" name="image1" stretch="uniformtofill" verticalalignment="top" width="auto" source="/abcdisplay;component/views/blue-pushpin2.jpg" opacity="1" /> 

 
<textbox height="23" horizontalalignment="left" name="textbox1" verticalalignment="top" width="120" text= "this test" /> 
</grid> 

 
</controltemplate>

@ runtime creating instance of template , assigning pushpin

pushpin2.template = ctype(me.resources("pintemplate"), controltemplate)

want assign text label/textblock thing count of values.
how can ? contents different each pin

one way use of databinding:

you can set text property of your textbox databound  this:

text= "{binding pintext}"


 

now in code behind create proerty this:

public class buttonvm          {              public string pintext { get; set; }          }


 

& set datacontext of button:

 buttonvm bvm = new buttonvm();              bvm.pintext = "count 1";              pushpin1.datacontext = bvm;

for different buttons u need create different classes!
demo code. plz explore mvvm pattern this.



Silverlight  >  Silverlight Controls and Silverlight Toolkit



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607