Skip to content

Commit 1e66d7b

Browse files
authored
Merge pull request #58 from unoplatform/dev/xygu/20190918/info-area-covering-demo
fixed demo area being covered by info area in narrow-state
2 parents b7cfc2d + 3fb5846 commit 1e66d7b

File tree

4 files changed

+64
-13
lines changed

4 files changed

+64
-13
lines changed

Microsoft.Toolkit.Uwp.SampleApp.Shared/Microsoft.Toolkit.Uwp.SampleApp.Shared.projitems

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@
385385
</Compile>
386386
<Compile Include="$(MSBuildThisFileDirectory)Styles\ThemeInjector.cs" />
387387
<Compile Include="$(MSBuildThisFileDirectory)TrackingManager.cs" />
388+
<Compile Include="$(MSBuildThisFileDirectory)Triggers\PaneStateTrigger.cs" />
388389
<Compile Include="$(MSBuildThisFileDirectory)UnoPlatformShell.cs" />
389390
</ItemGroup>
390391
<ItemGroup>
@@ -465,7 +466,6 @@
465466
<Content Include="$(MSBuildThisFileDirectory)Assets\UWPCommunityToolkitSampleAppAppList.scale-200.png" />
466467
<Content Include="$(MSBuildThisFileDirectory)Assets\UWPCommunityToolkitSampleAppAppList.scale-400.png" />
467468
</ItemGroup>
468-
469469
<!-- Workaround for https://github.com/unoplatform/uno/issues/1370 -->
470470
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != 'MonoAndroid'">
471471
<Content Include="$(MSBuildThisFileDirectory)Assets\UWPCommunityToolkitSampleAppAppList.targetsize-16.png" />

Microsoft.Toolkit.Uwp.SampleApp.Shared/Pages/SampleController.xaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
xmlns:common="using:Microsoft.Toolkit.Uwp.SampleApp.Common"
1414
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
1515
xmlns:models="using:Microsoft.Toolkit.Uwp.SampleApp.Models"
16-
mc:Ignorable="d xamarin">
16+
xmlns:triggers="clr-namespace:Microsoft.Toolkit.Uwp.SampleApp.Shared.Triggers"
17+
mc:Ignorable="d xamarin">
1718

1819
<Grid>
1920

@@ -93,7 +94,7 @@
9394
Grid.Column="1"
9495
Width="50"
9596
Visibility="Collapsed"
96-
Click="{x:Bind OpenClosePane}">
97+
Click="NarrowInfoButton_OnClick">
9798
<AppBarButton.Icon>
9899
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE946;" />
99100
</AppBarButton.Icon>
@@ -169,8 +170,8 @@
169170
Visibility="{x:Bind CanChangePaneState}"
170171
Icon="ClosePane"
171172
Width="50"
172-
Height="50"
173-
Click="{x:Bind ExpandCollapsePane}" />
173+
Height="50"
174+
Click="ExpandPane_OnClick" />
174175
</Pivot.LeftHeader>
175176

176177
<PivotItem x:Name="PropertiesPivotItem"
@@ -255,7 +256,7 @@
255256
StackMode="QueueBehind"
256257
Margin="10"
257258
Canvas.ZIndex="999" />
258-
259+
259260
<Grid x:Name="waitRing"
260261
Grid.Row="1"
261262
Grid.RowSpan="3"
@@ -271,6 +272,7 @@
271272
IsActive="True" />
272273
</Grid>
273274
</Grid>
275+
274276
<VisualStateManager.VisualStateGroups>
275277
<VisualStateGroup x:Name="WindowStates"
276278
CurrentStateChanged="WindowStates_CurrentStateChanged">
@@ -283,7 +285,7 @@
283285
<VisualState.Setters>
284286
<Setter Target="NarrowInfoButton.Visibility" Value="Visible" />
285287
<Setter Target="SampleTitleBar.(Grid.ColumnSpan)" Value="2" />
286-
<Setter Target="InfoAreaPivot.Margin" Value="0,50,0,0" />
288+
<Setter Target="InfoAreaGrid.Margin" Value="0,50,0,0" />
287289

288290
<Setter Target="InfoAreaGrid.(Grid.Column)" Value="0" />
289291
<Setter Target="InfoAreaGrid.(Grid.ColumnSpan)" Value="2" />
@@ -302,14 +304,14 @@
302304
CurrentStateChanged="PaneStates_CurrentStateChanged">
303305
<VisualState x:Name="Full">
304306
<VisualState.StateTriggers>
305-
<StateTrigger IsActive="{x:Bind SidePaneState.Equals(models:PaneState.Full), Mode=OneWay}" />
307+
<triggers:PaneStateTrigger Binding="{x:Bind SidePaneState, Mode=OneWay}" Value="Full" />
306308
</VisualState.StateTriggers>
307309
<VisualState.Setters>
308310
<Setter Target="InfoAreaGrid.Visibility" Value="Visible" />
309311
<Setter Target="ExpandPane.Icon" Value="OpenPane" />
310312
<Setter Target="SampleTitleBar.(Grid.ColumnSpan)" Value="1" />
311313
<Setter Target="SampleTitleBar.(Grid.Column)" Value="0" />
312-
<Setter Target="InfoAreaPivot.Margin" Value="0,50,0,0" />
314+
<Setter Target="InfoAreaGrid.Margin" Value="0,50,0,0" />
313315

314316
<Setter Target="InfoAreaGrid.(Grid.Column)" Value="0" />
315317
<Setter Target="InfoAreaGrid.(Grid.ColumnSpan)" Value="2" />
@@ -320,7 +322,7 @@
320322
</VisualState>
321323
<VisualState x:Name="Show">
322324
<VisualState.StateTriggers>
323-
<StateTrigger IsActive="{x:Bind SidePaneState.Equals(models:PaneState.Normal), Mode=OneWay}" />
325+
<triggers:PaneStateTrigger Binding="{x:Bind SidePaneState, Mode=OneWay}" Value="Normal" />
324326
</VisualState.StateTriggers>
325327
<VisualState.Setters>
326328
<Setter Target="InfoAreaGrid.Visibility" Value="Visible" />
@@ -329,7 +331,7 @@
329331
</VisualState>
330332
<VisualState x:Name="Hide">
331333
<VisualState.StateTriggers>
332-
<StateTrigger IsActive="{x:Bind SidePaneState.Equals(models:PaneState.Closed), Mode=OneWay}" />
334+
<triggers:PaneStateTrigger Binding="{x:Bind SidePaneState, Mode=OneWay}" Value="Closed" />
333335
</VisualState.StateTriggers>
334336
<VisualState.Setters>
335337
<Setter Target="InfoAreaGrid.Visibility" Value="Collapsed" />
@@ -338,7 +340,7 @@
338340
</VisualState>
339341
<VisualState x:Name="None">
340342
<VisualState.StateTriggers>
341-
<StateTrigger IsActive="{x:Bind SidePaneState.Equals(models:PaneState.None), Mode=OneWay}" />
343+
<triggers:PaneStateTrigger Binding="{x:Bind SidePaneState, Mode=OneWay}" Value="None" />
342344
</VisualState.StateTriggers>
343345
<VisualState.Setters>
344346
<Setter Target="InfoAreaGrid.Visibility" Value="Collapsed" />

Microsoft.Toolkit.Uwp.SampleApp.Shared/Pages/SampleController.xaml.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public ElementTheme GetActualTheme()
108108
return theme;
109109
}
110110

111+
private async void NarrowInfoButton_OnClick(object sender, RoutedEventArgs e) => OpenClosePane();
112+
111113
public void OpenClosePane()
112114
{
113115
if (CanChangePaneState)
@@ -123,6 +125,8 @@ public void OpenClosePane()
123125
}
124126
}
125127

128+
private async void ExpandPane_OnClick(object sender, RoutedEventArgs e) => ExpandCollapsePane();
129+
126130
public void ExpandCollapsePane()
127131
{
128132
if (CanChangePaneState)
@@ -328,7 +332,11 @@ void setSampleDataContext()
328332
}
329333
else
330334
{
331-
SidePaneState = _onlyDocumentation ? PaneState.Full : PaneState.Normal;
335+
SidePaneState = _onlyDocumentation
336+
? PaneState.Full
337+
: ((FrameworkElement)Windows.UI.Xaml.Window.Current.Content).ActualWidth > 700
338+
? PaneState.Normal
339+
: PaneState.Closed;
332340
}
333341

334342
Shell.Current.SetAppTitle($"{CurrentSample.CategoryName} > {CurrentSample.Name}");
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Microsoft.Toolkit.Uwp.SampleApp.Models;
5+
using Windows.UI.Xaml;
6+
7+
namespace Microsoft.Toolkit.Uwp.SampleApp.Shared.Triggers
8+
{
9+
public class PaneStateTrigger : StateTriggerBase
10+
{
11+
#region Property: Binding
12+
public static readonly DependencyProperty BindingProperty = DependencyProperty.Register(
13+
nameof(Binding),
14+
typeof(PaneState),
15+
typeof(PaneStateTrigger),
16+
new PropertyMetadata(default(PaneState), (s, e) => (s as PaneStateTrigger)?.UpdateTrigger()));
17+
18+
public PaneState Binding
19+
{
20+
get => (PaneState)GetValue(BindingProperty);
21+
set => SetValue(BindingProperty, value);
22+
}
23+
#endregion
24+
25+
#region Property: Value
26+
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
27+
nameof(Value),
28+
typeof(PaneState),
29+
typeof(PaneStateTrigger),
30+
new PropertyMetadata(default(PaneState), (s, e) => (s as PaneStateTrigger)?.UpdateTrigger()));
31+
32+
public PaneState Value
33+
{
34+
get => (PaneState)GetValue(ValueProperty);
35+
set => SetValue(ValueProperty, value);
36+
}
37+
#endregion
38+
39+
private void UpdateTrigger() => SetActive(Binding == Value);
40+
}
41+
}

0 commit comments

Comments
 (0)