Skip to content

Commit

Permalink
Fix maps, Windows StaggeredPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavAntonyuk committed May 12, 2024
1 parent af4cdb7 commit 42862bf
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions MauiMaps/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static MauiApp CreateMauiApp()
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>().UseMauiMaps()
.UseMauiCommunityToolkit()
.UseMauiMaps()
.UseMauiCommunityToolkitMaps("YOUR_KEY"); // https://learn.microsoft.com/en-us/bingmaps/getting-started/bing-maps-dev-center-help/getting-a-bing-maps-key
builder.RegisterAppServices()
.RegisterViewModels()
Expand Down
9 changes: 6 additions & 3 deletions MauiStaggeredCollectionView/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override ItemsViewLayout SelectLayout()

if (itemsLayout is StaggeredItemsLayout staggeredItemsLayout)
{
return new StagerredItemsViewLayout(staggeredItemsLayout, ItemsView.ItemSizingStrategy);
return new StaggeredItemsViewLayout(staggeredItemsLayout, ItemsView.ItemSizingStrategy);
}

return base.SelectLayout();
Expand All @@ -78,9 +78,12 @@ protected override ItemsViewLayout SelectLayout()
#if WINDOWS
protected override Microsoft.UI.Xaml.Controls.ListViewBase SelectListViewBase()
{
return this.VirtualView.ItemsLayout switch
return VirtualView.ItemsLayout switch
{
StaggeredItemsLayout staggeredItemsLayout => new Microsoft.UI.Xaml.Controls.GridView() { },
StaggeredItemsLayout staggeredItemsLayout => new Microsoft.UI.Xaml.Controls.GridView()
{
ItemsPanel = (Microsoft.UI.Xaml.Controls.ItemsPanelTemplate)Microsoft.UI.Xaml.Application.Current.Resources["StaggeredItemsPanel"]
},
_ => base.SelectListViewBase()
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-windows10.0.19041.0'">
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives">
<Version>7.1.2</Version>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Maui.Controls.Handlers.Items;
using UIKit;

public class StagerredItemsViewLayout(StaggeredItemsLayout itemsLayout, ItemSizingStrategy sizingStrategy)
public class StaggeredItemsViewLayout(StaggeredItemsLayout itemsLayout, ItemSizingStrategy sizingStrategy)
: ItemsViewLayout(itemsLayout, sizingStrategy)
{
private readonly List<UICollectionViewLayoutAttributes> cache = new();
Expand Down
7 changes: 6 additions & 1 deletion MauiStaggeredCollectionView/Platforms/Windows/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:MauiStaggeredCollectionView.WinUI">
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls">

<maui:MauiWinUIApplication.Resources>
<ItemsPanelTemplate x:Name="StaggeredItemsPanel">
<controls:StaggeredPanel />
</ItemsPanelTemplate>
</maui:MauiWinUIApplication.Resources>
</maui:MauiWinUIApplication>
4 changes: 0 additions & 4 deletions MauiStaggeredCollectionView/Platforms/Windows/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ public App()
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

}

namespace CommunityToolkit.WinUI.UI.Controls
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Maui.Controls.Handlers.Items;
using UIKit;

public class StagerredItemsViewLayout(StaggeredItemsLayout itemsLayout, ItemSizingStrategy sizingStrategy)
public class StaggeredItemsViewLayout(StaggeredItemsLayout itemsLayout, ItemSizingStrategy sizingStrategy)
: ItemsViewLayout(itemsLayout, sizingStrategy)
{
private readonly List<UICollectionViewLayoutAttributes> cache = new();
Expand Down
8 changes: 7 additions & 1 deletion MauiStaggeredCollectionView/README.mdpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Article: https://vladislavantonyuk.github.io/articles/.NET-MAUI-CollectionView-w

## Images

![Android](https://ik.imagekit.io/VladislavAntonyuk/vladislavantonyuk/articles/54/54.png)
![Android](https://ik.imagekit.io/VladislavAntonyuk/vladislavantonyuk/articles/54/android.png)

![iOS](https://ik.imagekit.io/VladislavAntonyuk/vladislavantonyuk/articles/54/ios.png)

![MacCatalyst](https://ik.imagekit.io/VladislavAntonyuk/vladislavantonyuk/articles/54/maccatalyst.png)

![Windows](https://ik.imagekit.io/VladislavAntonyuk/vladislavantonyuk/articles/54/windows.png)

!INCLUDE "./md/footer.mdpp"
2 changes: 1 addition & 1 deletion md/thankyou.mdpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Thank You

Special thanks to my friends and sponsors: @PeterFucci, Gerald Versluis (jfversluis), @renatolopes, Glen Herman, Olexii, Brady, Yury Michurin, VToegel, Aleksander Rokic, Jeffrey Williams, TimKyn, Standa Mikes, Aaron Schaefer, AIvanHeerden, 7 M O X D, gbrewer, Ryan, @janhjordie, erossiniuk, David, Sab.
Special thanks to my friends and sponsors: @PeterFucci, Gerald Versluis (jfversluis), @renatolopes, Glen Herman, Olexii, Brady, Yury Michurin, VToegel, Aleksander Rokic, Jeffrey Williams, TimKyn, Standa Mikes, Aaron Schaefer, AIvanHeerden, 7 M O X D, gbrewer, Ryan, @janhjordie, erossiniuk, David, Sab, Andreas.

0 comments on commit 42862bf

Please sign in to comment.