If we wanna make the Button looks like TextBox it is easy,just add the TextBox as content of Button.But the reverse is not possible sice TextBox doesnt have Content property.So use Templating.
< TextBox Text="Hai" >
< TextBox.Template >
< ControlTemplate >
< Button Content="hai"/ >
< /ControlTemplate >
< /TextBox.Template >
< /TextBox >
CS Code
ControlTemplate ct=new ControlTemplate(typeof(TextBox));
FrameworkElementFactory fef=new FrameworkElementFactory(typeof(Button));
fef.SetValue(Button.ContentProperty,"hai");
ct.VisualTree =fef;
txt.Template = ct;
Friday, April 20, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment