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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:00:36+00:00 2026-05-16T23:00:36+00:00

I have an interesting problem. I’ve created a WPF UserControl which contains a button

  • 0

I have an interesting problem. I’ve created a WPF UserControl which contains a button using a template:

<Button x:Name="btnStart" Template="{StaticResource RoundedGlassButton}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="4" Height="32" Background="DarkGreen" Foreground="White" Width="72" Content="Start" />

When I place the UserControl on a parent control or form, the designer throws the error, “Could not create an instance of type ‘MyUserControl’.” However, while the designer won’t work, the application will still compile and I get the desired results at runtime. I’ve narrowed the problem down to the template applied to my button. When I remove the template, the designer works:

<Button x:Name="btnStart" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="4" Height="32" Background="DarkGreen" Foreground="White" Width="72" Content="Start" />

I use this particular template all over the place – so I know it works. It even works on other UserControls. I just can’t understand why it doesn’t work in this particular UserControl.

Anyone have any ideas? It’s hard to build a UI without being able to see the results in the visual designer.

Below is the markup for the template. Like I said, however, I’m using this all over the place with no problems. In fact, I’m even using it in other UserControls just fine. I’m just stumped as to why it won’t work for this particular code.

    <ControlTemplate x:Key="RoundedGlassButton" TargetType="{x:Type Button}">
    <ControlTemplate.Resources>
        <Storyboard x:Key="Timeline1">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Timeline2">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </ControlTemplate.Resources>
    <Border BorderBrush="#FF888888" BorderThickness="1,1,1,1" CornerRadius="4">
        <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="4">                
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.507*"/>
                    <RowDefinition Height="0.493*"/>
                </Grid.RowDefinitions>
                <Border Opacity="0" BorderThickness="2" BorderBrush="White" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="4">
                    <Border.BitmapEffect>
                        <BlurBitmapEffect Radius="2" />
                    </Border.BitmapEffect>                       
                </Border>
                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" Grid.RowSpan="2" SnapsToDevicePixels="True" />
                <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,8,8">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">
                            <GradientStop Color="#AAFFFFFF" Offset="0"/>
                            <GradientStop Color="#33FFFFFF" Offset="1"/>
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>
            </Grid>
        </Border>
    </Border>
    <ControlTemplate.Triggers>
        <Trigger Property="IsPressed" Value="True">
            <Setter Property="Opacity" TargetName="shine" Value="0.4"/>
            <Setter Property="Background" TargetName="border" Value="#CC000000"/>
            <Setter Property="Visibility" TargetName="glow" Value="Hidden"/>
        </Trigger>
        <Trigger Property="IsMouseOver" Value="True">
            <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
            </Trigger.EnterActions>
            <Trigger.ExitActions>
                <BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/>
            </Trigger.ExitActions>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>

Due to project deadlines, I moved the markup directly into the parent control to get around the problem for now. That said, if anyone has any ideas on what could be causing the problem – any help would still be appreciated.

  • 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-16T23:00:37+00:00Added an answer on May 16, 2026 at 11:00 pm

    Ok, I’m fairly embarrassed. As it turns out, I forgot to add a reference to the resource containing the template at the top of my UserControl markup. The first few lines of markup in my UserControl file should have looked something like the following:

        <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/MyTemplates/MyTemplate.xaml" />
            </ResourceDictionary.MergedDictionaries>...
    

    It’s curious, though, that only the designer complained while the application still compiled and worked properly.

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

Sidebar

Related Questions

I have an interesting problem when using partial page update in asp.net with scriptmanager
I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
So I have an interesting problem here. I am using URL Routing to mask
I have an interesting problem. I'm using visual basic and before saving a row
I have an interesting problem. I have a page containing a Telerik chart which
I have an interesting problem. I currently have a basic template library that renders
I have came across very interesting problem which I think it's on Salesforce's end
I have a very interesting problem. I use this technologies in WPF app: Caliburn.Micro
I have run into an interesting problem which I'm pretty sure is the fault
I have an interesting problem which I've been looking into and would appreciate some

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.