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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:28:16+00:00 2026-05-28T15:28:16+00:00

I cannot seem to find anyone having a problem similar to this anywhere… So

  • 0

I cannot seem to find anyone having a problem similar to this anywhere…

So I have a custom control that inherits from Button. When I don’t apply a default style it loads the generic Button style and everything is fine and dandy. When I do apply a style the control renders as a pure white square without any functionality (clicking doesn’t work, etc.). I’m sure it is something in my style that is messing this up but when I apply the style through a key in XAML it works fine.

My code…

[TemplateVisualState(Name = "Normal", GroupName = "Common"),
TemplateVisualState(Name = "Disabled", GroupName = "Common"),
TemplateVisualState(Name = "Pressed", GroupName = "Common"),
TemplateVisualState(Name = "MouseOver", GroupName = "Common"),
TemplateVisualState(Name = "Alert", GroupName = "AlarmStates"),
TemplateVisualState(Name = "NoAlert", GroupName = "AlarmStates"),
TemplateVisualState(Name = "Warning", GroupName = "AlarmStates")]
public class AlarmButtonControl : Button
{
    /// <summary>
    /// Constructor
    /// </summary>
    public AlarmButtonControl()
    {
        this.DefaultStyleKey = typeof(AlarmButtonControl);
    }
}

and the XAML style is…

<ControlTemplate x:Key="StatusButton" >
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="Common">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.75" To="MouseOver"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Highlight2" d:IsOptimized="True"/>
                            <ColorAnimation Duration="0" To="#BF000000" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="Highlight2" d:IsOptimized="True"/>
                            <ColorAnimation Duration="0" To="#33666666" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="Base" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Highlight2" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Highlight1" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Viewbox Stretch="Fill">
                <Grid>
                    <Path x:Name="Base" 
                          StrokeThickness="1.0" 
                          Stroke="#ff000000" 
                          StrokeMiterLimit="1.0" 
                          Fill="{TemplateBinding Background}" Data="F1 M 99.500,99.500 L 0.500,99.500 L 0.500,0.500 L 99.500,0.500 L 99.500,99.500 Z"/>
                    <Rectangle x:Name="Highlight2" Fill="#3F000000" Margin="5" StrokeThickness="1.0" StrokeMiterLimit="1.0" Opacity="0"/>
                    <Path x:Name="Interior" Opacity="0.5" StrokeThickness="1.0" Stroke="#ff191919" StrokeMiterLimit="1.0" Data="F1 M 97.500,97.500 L 2.500,97.500 L 2.500,2.500 L 97.500,2.500 L 97.500,97.500 Z">
                        <Path.Fill>
                            <LinearGradientBrush MappingMode="Absolute" StartPoint="2.500,2.499" EndPoint="97.500,97.499">
                                <LinearGradientBrush.Transform>
                                    <MatrixTransform Matrix="1.000,0.000,-0.000,-1.000,0.000,100.000" />
                                </LinearGradientBrush.Transform>
                                <GradientStop Offset="0.00" Color="#3FFFFFFF"/>
                                <GradientStop Offset="0.151" Color="Transparent"/>
                                <GradientStop Offset="1.00" Color="#BFFFFFFF"/>
                                <GradientStop Color="#53FFFFFF" Offset="0.655"/>
                            </LinearGradientBrush>
                        </Path.Fill>
                    </Path>
                    <Path x:Name="LargeShader" Opacity="0.05" Fill="#ffffffff" Data="F1 M88.334,3.1789145E-07 L88.334,45.334 L0,45.334 C0,45.334 88.334,48.681 88.334,3.1789145E-07 z" Margin="6.333,49.333,5.333,5.284" UseLayoutRounding="False"/>
                    <Path x:Name="SmallShader" Opacity="0.05" Fill="#ffffffff" Data="F1 M74.333664,3.1789145E-07 L74.334,28.334332 L0,28.334332 C0,28.334332 60.000332,29.333 74.333664,3.1789145E-07 z" Height="28.339" Margin="20.333,0,5.333,5.328" UseLayoutRounding="False" VerticalAlignment="Bottom"/>
                    <Rectangle x:Name="Highlight1" Fill="#3FC0C0C0" Margin="5" StrokeThickness="1.0" StrokeMiterLimit="1.0" Opacity="0"/>
                </Grid>
            </Viewbox>
            <ContentPresenter x:Name="contentPresenter"
                              Height="{TemplateBinding Height}" 
                              Width="{TemplateBinding Width}" 
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              Margin="5"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>
    </ControlTemplate>

Any help would be greatly 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-28T15:28:17+00:00Added an answer on May 28, 2026 at 3:28 pm

    You haven’t include a Style just a ControlTemplate. Also for a default style you should be assiging the TargetType property of the style only. Something like the follow ought to be in the themes\generic.xaml file:

    <Style TargetType="local:AlarmButtonControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AlarmButtonControl">
                    <!-- Your template contents here -->
                </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 simple problem that I cannot seem to find a solution to.
I have a relatively simple question that I cannot seem to find the answer
i cannot seem to find the answer to this. i uploaded code to pastebin
I've been searching around for this and cannot seem to find a solid answer.
I have an htc Imagio. I cannot seem to find a Flash Player for
I've browsed the questions with similar titles but cannot seem to find exactly what
Hey, I have been looking on google and I cannot seem to find anything
I cannot seem to find a solid answer on this. I am a novice
I have Googled a bit, and cannot seem to find any examples of Xaml-fying
I've Googled, StackOverflowed, everything, and I cannot seem to find a tutorial I can

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.