Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7987511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:10:13+00:00 2026-06-04T12:10:13+00:00

in my Silverlight 4 application, I want to create a simple user control, that

  • 0

in my Silverlight 4 application, I want to create a simple user control, that can – beside other things – contain another control. An example for what I want is the Border-Control. You can put any other control (exactly ONE other control) “in” the Border-Control, so that the Border-Control contains the other user control and displays its content.
What do I need to do to create a user control with that capability? The idea is to put the other control in a ContentPresenter in my user control like:

<Grid x:Name="LayoutRoot">
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition />
  </Grid.RowDefinitions>

  <TextBlock x:Name="TextBlockHeader" Text="{Binding Title, ElementName=userControl}" HorizontalAlignment="Left" Foreground="White" Margin="5,0"/>
  <ContentPresenter x:Name="ContentPresenterObject" Grid.Row="1" />
</Grid>

Now, what to do to be able to add (in Expression Blend) a child control to my UserControl and how to bind it against the ContentPresenter? Or is this a wrong approach?

Thanks in advance,
Frank

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:10:15+00:00Added an answer on June 4, 2026 at 12:10 pm

    I would recommend creating a custom control that inherits from ContentControl. Here is a nice blog post talking about UserControls and custom controls

    You would need to create a “Generic.xaml” that would define your xaml, and a cs class that would define your class.

    public class CustomControl: ContentControl
    {
        public CustomControl()
        {
            this.DefaultStyleKey = typeof(CustomControl);
        }
    }
    

    You xaml class would look something like:

    <ResourceDictionary
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:MyApp">
    
    <Style TargetType="local:CustomControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CustomControl">
                    <Grid x:Name="LayoutRoot">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock x:Name="TextBlockHeader" Text="{Binding Title,
                                   ElementName=userControl}" HorizontalAlignment="Left" 
                                   Foreground="White" Margin="5,0"/>
                        <ContentPresenter x:Name="ContentPresenter" Grid.Row="1"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a silverlight application that contains Bing map. I want when the user
I create a C# - Silverlight 4 Application, that consists of some User Controls
I have Vista with IIS7 . I want to create a simple Silverlight application
I'm writing a silverlight application that resembles a shopping cart system. This app can
I really want to create a stunning-looking GUI desktop application that looks like, for
i am designing a silverlight application in which i want to level of user
i have develop a silverlight application with wcf net.tcp binding. i want create an
I have to create a publish-subscribe silverlight application. and the class that publishes the
I am working on a Silverlight web application that creates PDF documents. We want
I want to create a Wizard in my Silverlight MVVM application. The Wizard should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.