Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF adding control with using code behind

$
0
0

I have wpf control like this as Singleton control

public class ImageController : GraphicController
    {
        public ImageController()
            : base()
        {
            // some code //
        }

        private static ImageController instanceProperty;
        public static ImageController instance
        {
            get {
                if (instanceProperty == null)
                    instanceProperty = new ImageController();
                return instanceProperty; }
        }

    }

Now I have another Control ToolBox.xaml like below.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ....>
 <Style x:Key="ToolBoxStyle" TargetType="{x:Type controls:ToolBox}">
<Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:ToolBox}" x:Name="tests">
<Grid Margin="0" Grid.Column="0" Grid.Row="0" x:Name="resizableGrid">

// here i want to add ImageControl from codebehind by usin its instance.

</Grid>
</ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

Here I want to add ImageControl from ToolBox.cs file to inside that Grid. I want to do that because of there
are copuple of places in my aplication I use same control and needs to share it's property.

Please let me know how I can do binding here to add control from code behind

Thanks

Dee

 

Viewing all articles
Browse latest Browse all 18858

Trending Articles