[UWP][VB][XAML]Preventing Button.IsEnabled from Changing A Button Appearance in a UWP App RRS feed

  • Question

  • I have the following ControlTemplate for a Button in a UWP app:
    <ControlTemplate TargetType="Button">
    	<Grid Background="Transparent" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
    			<VisualStateGroup x:Name="CommonStates">
    				<VisualState x:Name="Normal"/>
    				<VisualState x:Name="MouseOver"/>
    				<VisualState x:Name="Pressed"/>
    				<VisualState x:Name="Disabled"/>
    		<Border x:Name="ButtonBackground" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0" Background="{TemplateBinding Background}" Margin="0" Padding="{TemplateBinding Padding}">
    			<ContentControl x:Name="ContentContainer" Background="Transparent" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0" Padding="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
    At certain points in my app I set the Foreground, Background, and IsEnabled properties of the Button. I want to set all three of these properties manually, which is why the VisualState(s) are empty. However, setting the IsEnabled property still changes the Foreground, which I am told has something to do with the value being hardcoded into triggers. However, UWP does not seem to have those triggers accessible. Is there any way I can prevent IsEnabled from changing the appearance of the Button? Thanks.

    Nathan Sokalski

    Thursday, July 11, 2019 5:06 PM

All replies

  • Hi,

    I could not reproduce the behavior you said with the code snippet you gave. The Example button is using your template and I changed it's state when test button click. And the Example button doesn't change at all no matter how I change the it's IsEnabled property.

    What's the OS version of your device? And what's the target version of your app? Could you share more code about how you reproduce this behavior?

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, July 12, 2019 2:53 AM