-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
StateTriggersDirectlyOnElements.xaml
61 lines (61 loc) · 3.21 KB
/
StateTriggersDirectlyOnElements.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodels="clr-namespace:Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries"
x:Class="Xamarin.Forms.Controls.GalleryPages.VisualStateManagerGalleries.StateTriggersDirectlyOnElements"
Title="StateTriggers directly on Elements">
<ContentPage.BindingContext>
<viewmodels:StateTriggersDirectlyOnElementsViewModel />
</ContentPage.BindingContext>
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Wide">
<VisualState.StateTriggers>
<CompareStateTrigger Property="{Binding ToggleState}" Value="True" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Green" />
<Setter TargetName="InfoLabel" Property="Label.Text" Value="Wide (CompareStateTrigger)"/>
<Setter TargetName="InfoLabel" Property="Label.FontSize" Value="24"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Narrow">
<VisualState.StateTriggers>
<CompareStateTrigger Property="{Binding ToggleState}" Value="False" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Red" />
<Setter TargetName="InfoLabel" Property="Label.Text" Value="Narrow (CompareStateTrigger)"/>
<Setter TargetName="InfoLabel" Property="Label.FontSize" Value="12"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Medium">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Blue" />
<Setter TargetName="InfoLabel" Property="Label.Text" Value="Medium (AdaptiveTrigger)"/>
<Setter TargetName="InfoLabel" Property="Label.FontSize" Value="18"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Button
Text="Click to toggle BackgroundColor"
Command="{Binding ToggleCommand}"
HorizontalOptions="Center"
VerticalOptions="Center" />
<Label
Grid.Row="1"
x:Name="InfoLabel"/>
</Grid>
</ContentPage.Content>
</ContentPage>