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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:48:23+00:00 2026-05-23T00:48:23+00:00

I followed a tutorial to make a Custom Control. What I basically did was

  • 0

I followed a tutorial to make a Custom Control. What I basically did was make a new project, add a file CategoryBar.cs and a directory called Themes with a file Themes\generic.xaml (with Compile type set to ‘resource’). Then I wrote a class CategoryBar.cs, filled up the generic.xaml with a ResourceDictionary. Let’s call this project the ‘UILib’:

<?xml version="1.0" encoding="utf-8" ?> 
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
                xmlns:local="clr-namespace:ErnestUILib">
    <Style TargetType="local:CategoryBar">
        <Setter Property="Background" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CategoryBar">
                        <Grid x:Name="GridView" Background="{TemplateBinding Background}" Margin="0,0,0,8">
                            <!-- The grid rowdefs, coldefs and whatever makes up the grid -->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

And it all runs completely fine in a project where I add a reference to this library. I added the attribute xmlns:EULib="clr-namespace:UILib;assembly=UILib" to <phone:PhoneApplicationPage .. /> and it’s working fine. Now, I wanted to implement another control (as I want to have one separate and exactly one library for custom UI controls). So now my generic.xaml looks like:

<?xml version="1.0" encoding="utf-8" ?> 
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
                xmlns:local="clr-namespace:ErnestUILib">
    <!-- THE NEW CUSTOM CONTROL -->
    <Style TargetType="local:PaginationBar">
        <Setter Property="Background" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PaginationBar">
                        <Grid x:Name="GridView" Background="{TemplateBinding Background}" Margin="0,0,0,8">
                            <!-- The grid rowdefs, coldefs and whatever makes up the grid -->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- THE PREVIOUS CUSTOM CONTROL -->
    <Style TargetType="local:CategoryBar">
        <Setter Property="Background" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CategoryBar">
                        <Grid x:Name="GridView" Background="{TemplateBinding Background}" Margin="0,0,0,8">
                            <!-- The grid rowdefs, coldefs and whatever makes up the grid -->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

Here, I’ve created a class PaginationBar in PaginationBar.cs and it’s all setup, but when I try to use it in my application’s xaml file, it shows a white-filled rectangle in the designer view with a cross at it’s top left corner and it says that an exception was caused ‘Control_TargetTypeMismatch’. After a few trickeries of mine, nothing still worked, but the Designer just doesn’t load when I use <UILib:PaginationBar .. /> and instead gives an error System.Reflection.TargetInvocationException (Exception has been thrown by the target of an invocation). When I run the project, it gives some XamlParseException error. This is the only exception I’m able to get some details out of, none of which I think are even remotely useful. Anyhow, this is what I get with the XamlParseException:XamlParseExceptionDetails

I have no clue how to proceed. Any help is greatly appreciated. Thanks in anticipation 🙂

  • 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-05-23T00:48:24+00:00Added an answer on May 23, 2026 at 12:48 am

    Verify that PaginationBar is define in the same namespace: “clr-namespace:ErnestUILib”. Also verify that you have set the right DefaultStyleKey in the constructor of your control:

     public PaginationBar ()
        {
            DefaultStyleKey = typeof(PaginationBar );
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this tutorial to make NUnit tests debugable in Visual Studio. In the
I've followed the tutorial from here: Twitter Client Tutorial to make a little twitter
I have followed this tutorial: http://www.phpjabbers.com/how-to-make-a-php-calendar-php26-6.html#comments to make a very basic calendar. My aim
I followed the tutorial at http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module step by step to make my module install
I followed the tutorial described here , in order to make the TinyMCE Spellchecker
I followed several tutorial to make this work, but I can't get draggable items.
I have followed the tutorial posted here in order to get AJAX file uploads
I have followed many a tutorial to make sure that this is correct but
I have followed the tutorial below to use CAGradientLayer to make gradient background in
I followed the tutorial from this site: http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/ to make my first iPhone application,

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.