Skip to content

Commit 1e5b000

Browse files
committed
Merge branch 'dev' of https://github.com/Microsoft/UWPCommunityToolkit into blurFix
2 parents 1b05bf9 + af6e507 commit 1e5b000

File tree

6 files changed

+70
-21
lines changed

6 files changed

+70
-21
lines changed

Microsoft.Toolkit.Uwp.SampleApp/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
3-
<Identity Name="52b9212c-97a9-4639-9426-3e1ea9c1569e" Publisher="CN=davca" Version="1.0.5.0" />
3+
<Identity Name="52b9212c-97a9-4639-9426-3e1ea9c1569e" Publisher="CN=davca" Version="1.2.0.0" />
44
<mp:PhoneIdentity PhoneProductId="52b9212c-97a9-4639-9426-3e1ea9c1569e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
55
<Properties>
66
<DisplayName>Microsoft.Toolkit.Uwp.SampleApp</DisplayName>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AdaptiveGridView/AdaptiveGridViewCode.bind

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
</Page.Resources>
2424
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
2525
<controls:AdaptiveGridView Name="control"
26-
ItemHeight="@[ItemHeight:Slider:200:50-500]"
27-
DesiredWidth="@[DesiredWidth:Slider:300:50-500]"
28-
SelectionMode="@[SelectionMode:Enum:ListViewSelectionMode.Single]"
29-
IsItemClickEnabled="@[IsItemClickEnabled:Bool:true]"
30-
ItemTemplate="{StaticResource PhotosTemplate}"/>
26+
OneRowModeEnabled="@[OneRowModeEnabled:Bool:false]"
27+
ItemHeight="@[ItemHeight:Slider:200:50-500]"
28+
DesiredWidth="@[DesiredWidth:Slider:300:50-500]"
29+
SelectionMode="@[SelectionMode:Enum:ListViewSelectionMode.Single]"
30+
IsItemClickEnabled="@[IsItemClickEnabled:Bool:true]"
31+
ItemTemplate="{StaticResource PhotosTemplate}"/>
3132
</Grid>
3233
</Page>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AdaptiveGridView/AdaptiveGridViewPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
<controls:AdaptiveGridView x:Name="AdaptiveGridViewControl"
4141
Grid.Row="1"
42+
OneRowModeEnabled="{Binding OneRowModeEnabled.Value}"
4243
DesiredWidth="{Binding DesiredWidth.Value}"
4344
IsItemClickEnabled="{Binding IsItemClickEnabled.Value, Mode=TwoWay}"
4445
ItemHeight="{Binding ItemHeight.Value}"

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MasterDetailsView/MasterDetailsViewPage.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@
2929
</controls:MasterDetailsView.ItemTemplate>
3030
<controls:MasterDetailsView.DetailsTemplate>
3131
<DataTemplate>
32-
<RelativePanel Margin="24">
32+
<RelativePanel Margin="8">
3333
<Ellipse x:Name="FromEllipse"
3434
Width="50"
3535
Height="50"
3636
Fill="Gray" />
37-
<TextBlock Margin="12,-6,0,0"
37+
<TextBlock Margin="12,10,0,0"
38+
VerticalAlignment="Center"
3839
RelativePanel.RightOf="FromEllipse"
3940
Style="{ThemeResource SubtitleTextBlockStyle}"
4041
Text="{Binding From}" />
4142
<TextBlock x:Name="SubjectLine"
4243
RelativePanel.Below="FromEllipse"
44+
Margin="0,12,0,0"
4345
Style="{ThemeResource BodyTextBlockStyle}"
4446
Text="{Binding Subject}" />
4547
<TextBlock x:Name="Body"

Microsoft.Toolkit.Uwp.UI.Controls/AdaptiveGridView/AdaptiveGridView.Properties.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,7 @@ public partial class AdaptiveGridView
6969
private static void OnOneRowModeEnabledChanged(DependencyObject d, object newValue)
7070
{
7171
var self = d as AdaptiveGridView;
72-
73-
if ((bool)newValue)
74-
{
75-
var b = new Binding()
76-
{
77-
Source = self,
78-
Path = new PropertyPath("ItemHeight")
79-
};
80-
81-
self.SetBinding(GridView.MaxHeightProperty, b);
82-
ScrollViewer.SetVerticalScrollMode(self, ScrollMode.Disabled);
83-
ScrollViewer.SetVerticalScrollBarVisibility(self, ScrollBarVisibility.Hidden);
84-
}
72+
self.DetermineOneRowMode();
8573
}
8674

8775
private static void DesiredWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

Microsoft.Toolkit.Uwp.UI.Controls/AdaptiveGridView/AdaptiveGridView.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
3030
/// new column.</remarks>
3131
public partial class AdaptiveGridView : GridView
3232
{
33+
private bool _isLoaded;
34+
3335
/// <summary>
3436
/// Initializes a new instance of the <see cref="AdaptiveGridView"/> class.
3537
/// </summary>
@@ -39,6 +41,8 @@ public AdaptiveGridView()
3941
SizeChanged += OnSizeChanged;
4042
ItemClick += OnItemClick;
4143
Items.VectorChanged += ItemsOnVectorChanged;
44+
Loaded += OnLoaded;
45+
Unloaded += OnUnloaded;
4246
}
4347

4448
/// <summary>
@@ -134,6 +138,59 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs e)
134138
}
135139
}
136140

141+
private void OnLoaded(object sender, RoutedEventArgs e)
142+
{
143+
_isLoaded = true;
144+
DetermineOneRowMode();
145+
}
146+
147+
private void OnUnloaded(object sender, RoutedEventArgs e)
148+
{
149+
_isLoaded = false;
150+
}
151+
152+
private void DetermineOneRowMode()
153+
{
154+
if (_isLoaded)
155+
{
156+
var itemsWrapGridPanel = ItemsPanelRoot as ItemsWrapGrid;
157+
158+
if (OneRowModeEnabled)
159+
{
160+
var b = new Binding()
161+
{
162+
Source = this,
163+
Path = new PropertyPath("ItemHeight")
164+
};
165+
166+
if (itemsWrapGridPanel != null)
167+
{
168+
itemsWrapGridPanel.Orientation = Orientation.Vertical;
169+
}
170+
171+
this.SetBinding(GridView.MaxHeightProperty, b);
172+
173+
ScrollViewer.SetVerticalScrollMode(this, ScrollMode.Disabled);
174+
ScrollViewer.SetVerticalScrollBarVisibility(this, ScrollBarVisibility.Disabled);
175+
ScrollViewer.SetHorizontalScrollBarVisibility(this, ScrollBarVisibility.Visible);
176+
ScrollViewer.SetHorizontalScrollMode(this, ScrollMode.Enabled);
177+
}
178+
else
179+
{
180+
this.ClearValue(GridView.MaxHeightProperty);
181+
if (itemsWrapGridPanel != null)
182+
{
183+
itemsWrapGridPanel.Orientation = Orientation.Horizontal;
184+
}
185+
186+
ScrollViewer.SetVerticalScrollMode(this, ScrollMode.Enabled);
187+
ScrollViewer.SetVerticalScrollBarVisibility(this, ScrollBarVisibility.Visible);
188+
ScrollViewer.SetHorizontalScrollBarVisibility(this, ScrollBarVisibility.Disabled);
189+
ScrollViewer.SetHorizontalScrollMode(this, ScrollMode.Disabled);
190+
}
191+
}
192+
}
193+
137194
private void RecalculateLayout(double containerWidth)
138195
{
139196
if (containerWidth > 0)

0 commit comments

Comments
 (0)