Skip to content

Commit 60cd31d

Browse files
authored
Merge pull request #134 from Microsoft/dev
Resync
2 parents c060cbb + 6729e52 commit 60cd31d

File tree

4 files changed

+62
-71
lines changed

4 files changed

+62
-71
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public sealed partial class AdaptiveGridView
6262
DependencyProperty.Register(nameof(OneRowModeEnabled), typeof(bool), typeof(AdaptiveGridView), new PropertyMetadata(false, (o, e) => { OnOneRowModeEnabledChanged(o, e.NewValue); }));
6363

6464
/// <summary>
65-
/// Identifies the <see cref="VerticalScroll"/> dependency property.
65+
/// Identifies the <see cref="VerticalScrollMode"/> dependency property.
6666
/// </summary>
67-
private static readonly DependencyProperty VerticalScrollProperty =
68-
DependencyProperty.Register(nameof(VerticalScroll), typeof(ScrollMode), typeof(AdaptiveGridView), new PropertyMetadata(ScrollMode.Auto));
67+
private static readonly DependencyProperty VerticalScrollModeProperty =
68+
DependencyProperty.Register(nameof(VerticalScrollMode), typeof(ScrollMode), typeof(AdaptiveGridView), new PropertyMetadata(ScrollMode.Auto));
6969

7070
/// <summary>
7171
/// Identifies the <see cref="ItemWidth"/> dependency property.
@@ -94,7 +94,7 @@ private static void OnOneRowModeEnabledChanged(DependencyObject d, object newVal
9494
};
9595

9696
self._listView.SetBinding(GridView.MaxHeightProperty, b);
97-
self.VerticalScroll = ScrollMode.Disabled;
97+
self.VerticalScrollMode = ScrollMode.Disabled;
9898
}
9999
}
100100
}
@@ -173,10 +173,10 @@ public bool OneRowModeEnabled
173173
/// </summary>
174174
public event ItemClickEventHandler ItemClick;
175175

176-
private ScrollMode VerticalScroll
176+
private ScrollMode VerticalScrollMode
177177
{
178-
get { return (ScrollMode)GetValue(VerticalScrollProperty); }
179-
set { SetValue(VerticalScrollProperty, value); }
178+
get { return (ScrollMode)GetValue(VerticalScrollModeProperty); }
179+
set { SetValue(VerticalScrollModeProperty, value); }
180180
}
181181

182182
private double ItemWidth

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
1010
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
1111
// ******************************************************************
12+
using System.Collections.Generic;
1213
using Windows.UI.Xaml;
1314
using Windows.UI.Xaml.Controls;
1415

@@ -47,17 +48,13 @@ private void RecalculateLayout(double containerWidth)
4748
return;
4849
}
4950

50-
if (_columns == 0)
51-
{
52-
_columns = CalculateColumns(containerWidth, DesiredWidth);
53-
}
54-
else
51+
_columns = CalculateColumns(containerWidth, DesiredWidth);
52+
53+
// If there's less items than there's columns, reduce the column count;
54+
if (_listView != null && _listView.Items != null
55+
&& _listView.Items.Count > 0 && _listView.Items.Count < _columns)
5556
{
56-
var desiredColumns = CalculateColumns(containerWidth, DesiredWidth);
57-
if (desiredColumns != _columns)
58-
{
59-
_columns = desiredColumns;
60-
}
57+
_columns = _listView.Items.Count;
6158
}
6259

6360
ItemWidth = (containerWidth / _columns) - 5;
@@ -75,6 +72,7 @@ protected override void OnApplyTemplate()
7572
{
7673
_listView.SizeChanged -= ListView_SizeChanged;
7774
_listView.ItemClick -= ListView_ItemClick;
75+
_listView.Items.VectorChanged -= ListViewItems_VectorChanged;
7876
_listView = null;
7977
}
8078

@@ -83,12 +81,23 @@ protected override void OnApplyTemplate()
8381
{
8482
_listView.SizeChanged += ListView_SizeChanged;
8583
_listView.ItemClick += ListView_ItemClick;
84+
_listView.Items.VectorChanged += ListViewItems_VectorChanged;
8685
}
8786

8887
_isInitialized = true;
8988
OnOneRowModeEnabledChanged(this, OneRowModeEnabled);
9089
}
9190

91+
private void ListViewItems_VectorChanged(Windows.Foundation.Collections.IObservableVector<object> sender, Windows.Foundation.Collections.IVectorChangedEventArgs @event)
92+
{
93+
if (_listView != null && !double.IsNaN(_listView.ActualWidth))
94+
{
95+
// If the item count changes, check if more or less columns needs to be rendered,
96+
// in case we were having fewer items than columns.
97+
RecalculateLayout(_listView.ActualWidth);
98+
}
99+
}
100+
92101
private void ListView_ItemClick(object sender, ItemClickEventArgs e)
93102
{
94103
var cmd = ItemClickCommand;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<ControlTemplate TargetType="controls:AdaptiveGridView">
99
<Grid>
1010
<ContentPresenter x:Name="templateProxy" Width="{TemplateBinding ItemWidth}" Height="{TemplateBinding ItemHeight}" ContentTemplate="{TemplateBinding ItemTemplate}" Visibility="Collapsed" />
11-
<GridView x:Name="ListView" IsItemClickEnabled="True" SelectionMode="None" IsSwipeEnabled="False" IsTabStop="False"
12-
ScrollViewer.VerticalScrollMode="{TemplateBinding VerticalScroll}" ScrollViewer.VerticalScrollBarVisibility="Hidden"
11+
<GridView HorizontalAlignment="Stretch" x:Name="ListView" IsItemClickEnabled="True" SelectionMode="None" IsSwipeEnabled="False" IsTabStop="False"
12+
ScrollViewer.VerticalScrollMode="{TemplateBinding VerticalScrollMode}" ScrollViewer.VerticalScrollBarVisibility="Hidden"
1313
ItemsSource="{TemplateBinding ItemsSource}">
1414
<GridView.ItemTemplate>
1515
<DataTemplate>

readme.md

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21,72 +21,54 @@ Once you search you should see a list similar to the one below (versions may be
2121

2222
![nuget packages](githubresources/images/NugetPackages.png "Nuget Packages")
2323

24-
### Base Toolkit (code only)
25-
26-
UWP Community Toolkit main NuGet package includes code only helpers for Colors, Internet Connection detection, Storage file handling, and a Stream helper class.
27-
28-
**Microsoft.Toolkit.Uwp**
29-
30-
### Notifications Package
31-
32-
Generate tile, toast, and badge notifications for Windows 10 via code. Includes intellisense support to avoid having to use the XML syntax.
33-
34-
**Microsoft.Toolkit.Uwp.Notifications**
35-
36-
**Microsoft.Toolkit.Uwp.Notifications.Javascript**
37-
38-
### Services Package
39-
This NuGet package includes the service helpers for Bing, Facebook, and Twitter.
40-
41-
**Microsoft.Toolkit.Uwp.Services**
42-
43-
### UI Packages
44-
Helpers and services that are built on top of Windows Composition layer to provide animations and XAML controls.
45-
46-
**Microsoft.Toolkit.Uwp.UI**
47-
48-
**Microsoft.Toolkit.Uwp.UI.Animations**
49-
50-
**Microsoft.Toolkit.Uwp.UI.Controls**
24+
| NuGet Package Name | description |
25+
| --- | --- |
26+
| [Microsoft.Toolkit.Uwp]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp.htm) | Main NuGet package includes code only helpers for Colors, Internet Connection detection, Storage file handling, and a Stream helper class. |
27+
| [Microsoft.Toolkit.Uwp.Notifications]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp_Notifications.htm) | Notifications Package - Generate tile, toast, and badge notifications for Windows 10 via code. Includes intellisense support to avoid having to use the XML syntax. |
28+
| Microsoft.Toolkit.Uwp.Notifications.Javascript | Notification Packages for JavaScript |
29+
| [Microsoft.Toolkit.Uwp.Services]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp_Services.htm) | Services Package - This NuGet package includes the service helpers for Bing, Facebook, and Twitter. |
30+
| [Microsoft.Toolkit.Uwp.UI]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp_UI.htm) | UI Packages - XAML converters, Visual tree extensions and helpers for your XAML UI. |
31+
| [Microsoft.Toolkit.Uwp.UI.Animations]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp_UI_Animations.htm) | Animations and Composition behaviors such as Blur, Fade, Rotate, etc. |
32+
| [Microsoft.Toolkit.Uwp.UI.Controls]({{site.baseurl}}/{{page.lang}}/api/Microsoft_Toolkit_Uwp_UI_Controls.htm) | XAML Controls such as RadialGauge, RangeSelector, etc. |
5133

5234
## Features
5335

5436
### Animations
5537

56-
- [Blur](animations/blur.md)
57-
- [Offset](animations/offset.md)
58-
- [Fade](animations/fade.md)
59-
- [Parallel](animations/parallax.md)
60-
- [Rotate](animations/rotate.md)
61-
- [Scale](animations/scale.md)
38+
* [Blur](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/animations/blur.htm)
39+
* [Offset](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/animations/offset.htm)
40+
* [Fade](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/animations/fade.htm)
41+
* [Rotate](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/animations/rotate.htm)
42+
* [Scale](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/animations/scale.htm)
6243

6344
### Controls
6445

65-
- [HamburgerMenu](controls/hamburgerMenu.md)
66-
- [HeaderedTextBlock](controls/headeredTextBlock.md)
67-
- [ImageEX](controls/ImageEx.md)
68-
- [PullToRefreshListView](controls/PullToRefreshListView.md)
69-
- [RadialGauge](controls/RadialGauge.md)
70-
- [RangeSelecter](controls/RangeSelector.md)
71-
- [AdaptiveGridView](controls/AdaptiveGridView.md)
72-
- [RotatorTile](controls/RotatorTile.md)
73-
- [SlideableListItem](controls/SlideableListItem.md)
46+
* [AdaptiveGridView](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/adaptivegridview.htm)
47+
* [HamburgerMenu](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/hamburgermenu.htm)
48+
* [HeaderedTextBlock](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/headeredtextblock.htm)
49+
* [ImageEX](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/imageex.htm)
50+
* [PullToRefreshListView](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/pulltorefreshlistview.htm)
51+
* [RadialGauge](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/radialgauge.htm)
52+
* [RangeSelector](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/rangeselector.htm)
53+
* [RotatorTile](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/rotatortile.htm)
54+
* [SlideableListItem](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/controls/slidablelistitem.htm)
7455

7556
### Code Helpers
7657

77-
- [Colors](helpers/colors.md)
78-
- [Connection](helpers/connectionHelper.md)
79-
- [ImageCache] (helpers/imagecache.md)
80-
- [StorageFiles](helpers/storagefiles.md)
81-
- [Streams](helpers/streams.md)
82-
- [VisualTreeExtensions](helpers/visualtreeextensions.md)
83-
- [WeakEventListener](helpers/weakeventlistener.md)
58+
* [Colors](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/colors.htm)
59+
* [Connection](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/connectionhelper.htm)
60+
* [Converters](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/converters.htm)
61+
* [ImageCache](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/imagecache.htm)
62+
* [StorageFiles](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/storagefiles.htm)
63+
* [Streams](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/streams.htm)
64+
* [VisualTreeExtensions](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/visualtreeextensions.htm)
65+
* [WeakEventListener](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/helpers/weakeventlistener.htm)
8466

8567
### Services
8668

87-
- [Bing](services/bing.md)
88-
- [Facebook](services/facebook.md)
89-
- [Twitter](services/twitter.md)
69+
* [Bing](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/services/bing.htm)
70+
* [Facebook](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/services/facebook.htm)
71+
* [Twitter](https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/services/twitter.htm)
9072

9173
### Notifications
9274
- [Tiles](https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/06/30/adaptive-tile-templates-schema-and-documentation/)

0 commit comments

Comments
 (0)