Create dll to display given text by clicking a button:

Create dll to display given text by clicking a button:
Step1:open Visual studio Dot.net and select the class library in silverlight and give a name for ur project. i gived it as exdll.



Step2:right click exdll from solution explorer and create a new folder named it as “themes”.under this folder create new .xaml file named it as “generic” don’t change this name.

*create one more new folder under “exdll” and named it as “cl” under this folder add a new class file named “txt” Step3:create design in “generic.xaml” file

Eg:





Step4: declaration and event codings are done in “txt.cs” file
Eg: namespace exdll.cl
{
public class txt : Control
{

public txt()
{
DefaultStyleKey = typeof(txt);

}

private TextBox text1;
private Button b1;

public override void OnApplyTemplate()
{
base.OnApplyTemplate();
text1 = base.GetTemplateChild("t1") as TextBox;
b1 = base.GetTemplateChild("btn") as Button;
if (b1 == null)
return;
if (text1 == null)
return;

b1.Click += new RoutedEventHandler(b1_click); //clickevent
}
void b1_click(object sender, RoutedEventArgs e)
{
string s = "hai";
text1.Text = s;

}
}
}
Step5:now build the project.
Step6:open new silverlight application and ur dll file.by right clicking tool box select “choositems” in the silverlight component select ur appropriate dll.then run ur project.

murughas...

Comments

Popular Posts