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

  • SEARCH
  • Home
  • 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 8262429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:45:12+00:00 2026-06-08T03:45:12+00:00

I am developing a WPF application, and have created a custom control, we will

  • 0

I am developing a WPF application, and have created a custom control, we will call it ‘CControl’. In the xaml document where I am designing the layout of my application. I import the style with:

xmlns:my="clr-namespace:My.Controls"

and am able to use the control just fine. The problem is I want to extend the style on CControl. In the Resource Dictionary, I am able to set:

        <Style TargetType="{x:Type my:CControl}">
            <Setter Property="Margin" Value="5 0 5 3" />
        </Style>

This applies the style to the Control, but doesn’t import the style defined by CControl, so I use:

        <Style TargetType="{x:Type my:CControl}" BasedOn="{StaticResource {x:Type my:CControl}}">
            <Setter Property="Margin" Value="5 0 5 3" />
        </Style>

The problem is when my framework tries to load the xaml I get the following exception:

System.Windows.Markup.XamlParseException occurred
  Message='Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '18' and line position '54'.
Source=PresentationFramework
LineNumber=18
LinePosition=54
StackTrace:
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, Boolean skipJournaledProperties, Uri baseUri)
   at System.Windows.Markup.XamlReader.Load(XamlReader xamlReader, ParserContext parserContext)
   at System.Windows.Markup.XamlReader.Load(XamlReader reader)
   at FATPOT.Whiteboard.Report.Show() in C:\...\Report.cs
InnerException: 
   Message=Cannot find resource named 'My.Controls.CControl'. Resource names are case sensitive.
   Source=PresentationFramework
   StackTrace:
        at System.Windows.StaticResourceExtension.ProvideValueInternal(IServiceProvider serviceProvider, Boolean allowDeferredReference)
        at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
        at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
   InnerException: 

I have tried different ways of using BasedOn and havent gotten anything to work. Any help would be extremely useful.

Thanks

Josh

  • 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-08T03:45:13+00:00Added an answer on June 8, 2026 at 3:45 am

    After trying for a day to get extend the custom control’s style, I was finally able to get it to work. You can use a control by defining the namespace, but if you want to extend the control’s style, you need to include the ResourceDictionary for the control. I ended up adding:

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/My.Project;component/Resources/CControl.xaml" />
            </ResourceDictionary.MergedDictionaries>
    

    to my ResourceDictionary in my WPF Applications Canvas / Xaml.

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

Sidebar

Related Questions

I'm developing a WPF application, and I have created a custom usercontrol because I
I am developing a WPF application, and I have created a user control called
I am developing an application in C# WPF which will have Client-Server architecture (Client
I'm developing a WPF application using MVVM. Inside a Window, I have a control
I am developing a WPF application, and I need your advice. I have to
Context: I'm developing a WPF application which will contain a lot of different screens.
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I'm currently developing a application where I will have multiple windows open using C#
i'm developing an application (wpf) that have 3 windows. in the main window user
I'm currently developing a WPF application in C# and I want to have a

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.