Reputation: 25
I am trying to change to BorderBrush of a Button based on an event.
I tried searching how to change visual states but all of the them use a combination of both VisualState.StateTriggers and VisualState.Setters. When I use them in my Style, I get error message "The member 'Setters' is not recognized or is not accessible".
Development Environment
.Net Framework 4.6.1
<Style x:Key="ButtonGameLarge" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup >
<VisualState x:Name="whateverName">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="RootGrid.Height" Value="80" />
<Setter Target="RootGrid.Width" Value="400" />
<Setter Target="RootGrid.Margin" Value="0,0,0,20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Upvotes: 0
Views: 1100
Reputation: 436
You mention that you're using Visual Studio 2013. However, according to Microsoft, you need at least Visual Studio 2015 to develop for UWP. My guess is that the "Universal" you selected is the old Windows 8.1-style "universal" which doesn't have the VisualState
capabilities of UWP. You're not really working with a UWP project at all.
Upvotes: 2
Reputation: 34306
I created an empty project in Visual Studio, pasted in your XAML code into my main page and applied the style to a button. It compiles and runs fine.
Are you sure your project is a Universal Windows project and not something older (like Windows Runtime which does not have StateTriggers
if I recall)? I'll need more information.
Upvotes: 0