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 9097373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:05:41+00:00 2026-06-17T00:05:41+00:00

I’ve created a custom control (my first) from the base class UserControl and now

  • 0

I’ve created a custom control (my first) from the base class UserControl and now I wan’t to be able to inherit from it when making future controls.

Here is the custom control template

<Style TargetType="{x:Type local:LoadOverlayUserControl}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:LoadOverlayUserControl}">
                <Grid>
                    <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"/>
                    <Border Visibility="{TemplateBinding OverlayVisibility}"
                            Background="{TemplateBinding OverlayColor}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <dxe:ProgressBarEdit />
                    </Border>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Here is the source code:

    public class LoadOverlayUserControl : UserControl
{
    static LoadOverlayUserControl()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(LoadOverlayUserControl), new FrameworkPropertyMetadata(typeof(LoadOverlayUserControl)));
    }

    #region Overlay Visibility
    public static readonly DependencyProperty OverlayVisibilityProperty = DependencyProperty.Register("OverlayVisibility",
        typeof(Visibility),
        typeof(LoadOverlayUserControl), 
        new PropertyMetadata(Visibility.Hidden));

    private Visibility OverlayVisibility
    {
        get
        {
            return (Visibility)this.GetValue(OverlayVisibilityProperty);
        }
        set
        {
            this.SetValue(OverlayVisibilityProperty, value);
        }
    }
    #endregion

    #region Overlay Color
    public static readonly DependencyProperty OverlayColorProperty = DependencyProperty.Register("OverlayColor",
        typeof(Color),
        typeof(LoadOverlayUserControl),
        new PropertyMetadata(Color.FromRgb(0,0,0)));

    public Color OverlayColor
    {
        get
        {
            return (Color)this.GetValue(OverlayColorProperty);
        }
        set
        {
            this.SetValue(OverlayColorProperty, value);
        }
    }
    #endregion

    public void SetLoading(bool IsLoading)
    {
        if (IsLoading)
        {
            OverlayVisibility = System.Windows.Visibility.Visible;
        }
        else
        {
            OverlayVisibility = System.Windows.Visibility.Hidden;
        }
    }
}

The problem I’ve run into is that when I inherit from this custom control, it seems to ignore my template and I end up with an empty control.

Here is an example of the new control that is inheriting from this custom control.

<custom:LoadOverlayUserControl x:Class "ChildControl"
...
...
...>

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="../ResourceDictionaries/Generic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>

<Grid>
...
</Grid>
</custom:LoadOverlayUserControl>

And here is how I am using the new control. I’ve omitted namespaces for readability but I assure you they are correct unless there is something tricky I need to do.

<UserControl x:Class "SomeOtherControl">
    <Grid>
    <StackPanel>
        <my:ChildControl />
    </StackPanel>  
    </Grid>
</UserControl>

The idea behind the custom control is for controls that I want to be able to apply a “Currently Loading” overlay on top of with semi-transparent opacity.

  • 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-17T00:05:42+00:00Added an answer on June 17, 2026 at 12:05 am

    When you want to create a custom control in WPF, you will want to do a few things differently.

    First, inherit from ContentControl, not UserControl.

    Second, your resource dictionary Generic.xaml should go under the Themes folder.

    Third, your derived control classes will also need to be WPF controls. That is, they will need to override the default style key, and define their style in Generic.xaml.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

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.