Introduction:
In this article,i am going to explain about how to add a custom controls in silverlight application (xaml).
Main:
For adding custom control in xaml page just add a reference to the assembly containing the custom control and
then add a clr-namespace reference via an xmlns attribute in the
1.Create a custom control (including dll),
2.Add refrence to silverlight application,
for ex,
<UserControl x:Class="Ch02_ProgrammingModel.Recipe2_2.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:SC="clr-namespace:cucontrol;assembly=customControl"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<SC:SimpleControl FullName="Rob Cameron and Jit Ghosh"
FontSize="18" f/>
</Grid>
</UserControl>
<UserControl x:Class="Ch02_ProgrammingModel.Recipe2_2.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:SC="clr-namespace:cucontrol;assembly=customControl" Width="400" Height="300"> <Grid x:Name="LayoutRoot" Background="White"> <SC:SimpleControl FullName="Rob Cameron and Jit Ghosh" FontSize="18" f/> </Grid> </UserControl> |
thatsit!
Conclusion:
Hope this helps,
Happy coding.
Comments are closed.