Dynamically creating TextBlock controls - Name /Border properties


i dynamically creating number of textblock controls. able controls display unable couple of things:

1.  want set name of control. however, when control.name following error:

property or indexer 'system.windows.dependencyobject.name' cannot assigned -- read only  

i thought maybe doing control.setvalue<string> 'x:name' not see how work

2.  there way draw border around textblock?  not see border or stroke properties.  know can creating rectangle object want dynamically show/hide border , running same problem being able set name property cannot it. 

here's code looks like:

                textblock mytext = new textblock();
                mytext.setvalue<double>(canvas.leftproperty, 10);
                mytext.setvalue<double>(canvas.topproperty, top);
                mytext.width = 100;
                mytext.height = fieldheight;
                mytext.fontsize = 13;
                mytext.text = entity.mnemonic;
                this.children.add(mytext);

 any appreciated

paul 

 

thanks quick responses.

i ended resolving doing following:

control.setvalue<string>( dependencyobject.nameproperty,"myname");

although guess there no answer border question...just have use rectangle object.



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........