textblock foreground problem
have following text block in mt mytest.xaml
<
textblock opacity="0.0" rendertransformorigin="0.5,0.5" width="140" height="43" canvas.left="2.0" canvas.top="1" fontsize ="0" fontstyle="normal" foreground="red" x:name="overlayed_text1"> and using folling to get/set values of text block code behind (mttest.xaml.cs) // setting/getting text
public string textelementtext{
get
{
return textelement.text;
}
set
{
textelement.text = value;
}
}
// setting/getting font size
public double textelementfontsize
{
get
{
return textelement.fontsize;
}
set
{
textelement.fontsize = value;
}
}
// setting/getting opacity
public double textelementopacity
{
get
{
return textelement.opacity;
}
set
{
textelement.opacity = value;
}
}
but stuck here, dont know how assign foreground value this..
public string textelementforeground
{
set
{
textelement.foreground = value
}
get
{
return textelement.foreground;
}
}
i thankful of positive reply let me fix this..thx all
ttyr this..
this lot..
using
system;using
system.windows.media;using
system.reflection; namespace ravs{
public class colorreflector{
public color getthiscolor(string colorstring){
type colortype = (typeof(system.windows.media.colors));if (thetype.getproperty(colorstring) != null){
object o = thetype.invokemember(colorstring, bindingflags.getproperty, null, null, null); if (o != null){
return (color)o;}
}
return colors.black;}
}
}
save above code in .cs file
to use in code
use this
ravs.
colorreflector cr = new ravs.colorreflector();string colortoapply=""yellow";
textelementforeground = new solidcolorbrush(cr.getthiscolor(colortoapply));
if answer helps mark answered
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment