Accessing Control in UserControl


hello,

 i have created usercontrol:

 

<usercontrol
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:ignorable="d"
x:class="main.shadow"
d:designwidth="640" d:designheight="480" x:name="myshadow">


<border cornerradius="13" borderthickness="1,1,1,1" borderbrush="#19000000" verticalalignment="center" horizontalalignment="center">
<border cornerradius="12" borderthickness="1,1,1,1" borderbrush="#33000000" >
<border cornerradius="11" borderthickness="1,1,1,1" borderbrush="#66000000">
<border cornerradius="11" borderthickness="1,1,1,1" borderbrush="#99000000">
<border cornerradius="10" borderthickness="1,1,1,1" borderbrush="#ff000000">
<border cornerradius="10" borderthickness="1,1,1,1" borderbrush="#ff000000" x:name="myborder" background="{staticresource mybackground}">
<canvas width="150" height="150">
</canvas>
</border>
</border>
</border>
</border>
</border>
</border>


</usercontrol>

  

when reuse usercontrol, how can access , add items containing canvas?

like that:

 <main:shadow height="131" horizontalalignment="left" margin="100,115,0,0" verticalalignment="top" width="158"

    ...add controls here

</main:shadow
        

hai!

thanks reply.

now found solution:

the xaml need in mycontrol of type canvas

<canvas x:class="myproject.mycontrol"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    width="auto" height="auto">
</canvas>

the code control:

using system.windows.controls;

namespace myproject
{
    public partial class mycontrol : canvas
    {
        public mycontrol()
        {
            //initializecomponent();
        }
    }
}

and usage of mycontrol:

 

<myproject:mycontrol height="138" horizontalalignment="left" margin="100,0,0,117" verticalalignment="bottom" width="205">
            <button height="25" width="82" content="button" canvas.left="0" canvas.top="0"/>
            <button height="25" width="82" content="button" canvas.left="0" canvas.top="30"/>
</myproject:mycontrol>

 

still working. maybe adding finetuning..



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........