Skip to content

Updated MAUI bindings to use new Compiled Bindings introduced in .NET 9 #630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3b468d7
Set version to 200.7
dotMorten Jan 13, 2025
d57658a
Order sample collection
dotMorten Jan 13, 2025
408a021
Add AoT support to Basemap Gallery
dotMorten Jan 13, 2025
47d80a1
Add x:Bind expressions to sample pages
dotMorten Jan 13, 2025
646b118
Add xaml generation to winui
dotMorten Jan 13, 2025
edcbd64
project settings cleanup
dotMorten Jan 13, 2025
6bdcaff
Avoid use of implicit datacontext bindings
dotMorten Jan 14, 2025
195879e
Rewrites several parts of the SearchView to make it AoT compatible in…
dotMorten Jan 16, 2025
7ed661e
Merge remote-tracking branch 'remotes/origin/main' into v.next
prathameshnarkhede Jan 24, 2025
f48524a
Merge main to v.next (#623)
prathameshnarkhede Jan 24, 2025
4de6a58
Fix maui version
dotMorten Jan 28, 2025
3c6abc9
Remove unused dependency
dotMorten Jan 28, 2025
0520e33
Update WinUI AoT table
dotMorten Jan 28, 2025
ac55bb3
Fix preview in compatibility table
dotMorten Jan 28, 2025
fe4c1ea
Add built-in barcode scanning (#615)
dotMorten Jan 28, 2025
3e2fbc8
Adding barcode scanner to Android (#624)
dotMorten Feb 2, 2025
32aa89f
Improve windows scanning performance by just using default scanner
dotMorten Feb 4, 2025
e3a7728
Update ios/catalyst target to 18.0 to match default ios tfm
dotMorten Feb 5, 2025
cd66dc9
Fix warnings in Android introduced by transitive packages by locking …
dotMorten Feb 6, 2025
82561c9
Fix indents
dotMorten Feb 6, 2025
3fc1d17
Merge branch 'v.next' of https://github.com/Esri/arcgis-maps-sdk-dotn…
prathameshnarkhede Feb 26, 2025
ecff211
Merge remote-tracking branch 'remotes/origin/main' into v.next
prathameshnarkhede Feb 26, 2025
75c9bbe
Support for BasemapGallery toolkit control to include 3D Basemaps (#628)
prathameshnarkhede Mar 19, 2025
7f63d7f
Updated MAUI bindings to use new Compiled Bindings introduced in .Net 9
prathameshnarkhede Mar 21, 2025
b2ca881
Correcting data bindings and tested the code.
prathameshnarkhede Mar 25, 2025
771357e
Remove unused directives and dependencies in FloorFilter
prathameshnarkhede Mar 25, 2025
fbbd201
Remove DynamicDependency attributes and update to correct bindings
prathameshnarkhede Mar 26, 2025
5cf3bd8
Merge branch 'main' into pratham/use-maui-compiled-bindings
prathameshnarkhede Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ private void SetMapViewBinding_Click(object? sender, EventArgs e)
_viewContainer.Children.Add(MyMapView);
if (_viewContainer.Children.Contains(MySceneView))
_viewContainer.Children.Remove(MySceneView);
Binding geoviewBinding = new Binding();
geoviewBinding.Source = MyMapView;
BookmarksView.SetBinding(Esri.ArcGISRuntime.Toolkit.Maui.BookmarksView.GeoViewProperty, geoviewBinding);
BookmarksView.SetBinding(Esri.ArcGISRuntime.Toolkit.Maui.BookmarksView.GeoViewProperty, static (MapView mapView) => mapView, source: MyMapView);
}

// Note that the Web Scene Specification does not use bookmarks.
Expand All @@ -55,9 +53,7 @@ private void SetSceneViewBinding_Click(object? sender, EventArgs e)
_viewContainer.Children.Add(MySceneView);
if (_viewContainer.Children.Contains(MyMapView))
_viewContainer.Children.Remove(MyMapView);
Binding geoviewBinding = new Binding();
geoviewBinding.Source = MySceneView;
BookmarksView.SetBinding(Esri.ArcGISRuntime.Toolkit.Maui.BookmarksView.GeoViewProperty, geoviewBinding);
BookmarksView.SetBinding(Esri.ArcGISRuntime.Toolkit.Maui.BookmarksView.GeoViewProperty, static (SceneView sceneView) => sceneView, source: MySceneView);
}

private void SetDocumentOne_Click(object? sender, EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<EnableMsixTooling>true</EnableMsixTooling>
<DefineConstants>$(DefineConstants);WINUI</DefineConstants>
<UseRidGraph>true</UseRidGraph>
<PublishAot>True</PublishAot>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// ******************************************************************************/

using Esri.ArcGISRuntime.Mapping.Floor;
using System.Diagnostics.CodeAnalysis;

namespace Esri.ArcGISRuntime.Toolkit.Maui;

Expand All @@ -27,11 +26,6 @@ public partial class FloorFilter
private static readonly DataTemplate DefaultDifferentiatingFacilityDataTemplate;
private static readonly ControlTemplate DefaultControlTemplate;


[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.Floor.FloorLevel.ShortName), "Esri.ArcGISRuntime.Mapping.Floor.FloorLevel", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.Floor.FloorFacility.Name), "Esri.ArcGISRuntime.Mapping.Floor.FloorFacility", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.Floor.FloorFacility.Site), "Esri.ArcGISRuntime.Mapping.Floor.FloorFacility", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.Floor.FloorSite.Name), "Esri.ArcGISRuntime.Mapping.Floor.FloorSite", "Esri.ArcGISRuntime")]
static FloorFilter()
{
DefaultLevelDataTemplate = new DataTemplate(() =>
Expand All @@ -56,7 +50,7 @@ static FloorFilter()
VerticalOptions = LayoutOptions.Fill,
InputTransparent = false,
};
textLabel.SetBinding(Label.TextProperty, "ShortName");
textLabel.SetBinding(Label.TextProperty, static (FloorLevel level) => level.ShortName);
containingGrid.Children.Add(textLabel);
return containingGrid;
});
Expand All @@ -73,7 +67,7 @@ static FloorFilter()
Margin = new Thickness(8),
HorizontalOptions = LayoutOptions.Fill
};
textLabel.SetBinding(Label.TextProperty, "Name");
textLabel.SetBinding(Label.TextProperty, static (FloorFacility facility) => facility.Name);
textLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb("#6e6e6e"), Color.FromArgb("#fff"));

containingGrid.Children.Add(textLabel);
Expand Down Expand Up @@ -111,7 +105,7 @@ static FloorFilter()
FontSize = 14,
};
titleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb("#6e6e6e"), Color.FromArgb("#fff"));
titleLabel.SetBinding(Label.TextProperty, "Name");
titleLabel.SetBinding(Label.TextProperty, static (FloorFacility facility) => facility.Name);

Label subtitleLabel = new Label
{
Expand All @@ -120,7 +114,7 @@ static FloorFilter()
VerticalOptions = LayoutOptions.Start,
};
subtitleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb("#2e2e2e"), Color.FromArgb("#aaa"));
subtitleLabel.SetBinding(Label.TextProperty, "Site.Name");
subtitleLabel.SetBinding(Label.TextProperty, static (FloorFacility facility) => facility.Site?.Name);
textStack.Children.Add(titleLabel);
textStack.Children.Add(subtitleLabel);
Grid.SetRow(titleLabel, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/Toolkit/Toolkit.Maui/FloorFilter/FloorFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ protected override void OnApplyTemplate()
{
PART_LevelListView.ItemTemplate = LevelDataTemplate;
PART_LevelListView.BindingContext = this;
PART_LevelListView.SetBinding(CollectionView.ItemsSourceProperty, new Binding(nameof(DisplayLevels), BindingMode.OneWay));
PART_LevelListView.SetBinding(CollectionView.SelectedItemProperty, new Binding(nameof(SelectedLevel), BindingMode.TwoWay));
PART_LevelListView.SetBinding(CollectionView.ItemsSourceProperty, nameof(DisplayLevels), BindingMode.OneWay);
PART_LevelListView.SetBinding(CollectionView.SelectedItemProperty, static (FloorFilter filter) => filter.SelectedLevel, BindingMode.TwoWay);
}
}

Expand Down
16 changes: 5 additions & 11 deletions src/Toolkit/Toolkit.Maui/Legend/Legend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// ******************************************************************************/

using Esri.ArcGISRuntime.Mapping;
using System.Diagnostics.CodeAnalysis;

namespace Esri.ArcGISRuntime.Toolkit.Maui;

Expand All @@ -29,36 +28,31 @@ public class Legend : TemplatedView
private static DataTemplate s_DefaultSublayerItemTemplate;
private static DataTemplate s_DefaultLegendInfoItemTemplate;
private static ControlTemplate s_DefaultControlTemplate;


[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.Layer.Name), "Esri.ArcGISRuntime.Mapping.Layer", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.ILayerContent.Name), "Esri.ArcGISRuntime.Mapping.ILayerContent", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.LegendInfo.Name), "Esri.ArcGISRuntime.Mapping.LegendInfo", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.LegendInfo.Symbol), "Esri.ArcGISRuntime.Mapping.LegendInfo", "Esri.ArcGISRuntime")]

static Legend()
{
s_DefaultLayerItemTemplate = new DataTemplate(() =>
{
var nameLabel = new Label { FontSize = 18, VerticalOptions = LayoutOptions.Center };
nameLabel.SetBinding(Label.TextProperty, $"{nameof(LegendEntry.Content)}.{nameof(Layer.Name)}");
nameLabel.SetBinding(Label.TextProperty, static (LegendEntry entry) => ((Layer)entry.Content).Name);
return nameLabel;
});

s_DefaultSublayerItemTemplate = new DataTemplate(() =>
{
var nameLabel = new Label { FontSize = 14, VerticalOptions = LayoutOptions.Center };
nameLabel.SetBinding(Label.TextProperty, $"{nameof(LegendEntry.Content)}.{nameof(ILayerContent.Name)}");
nameLabel.SetBinding(Label.TextProperty, static (LegendEntry entry) => ((ILayerContent)entry.Content).Name);
return nameLabel;
});

s_DefaultLegendInfoItemTemplate = new DataTemplate(() =>
{
StackLayout sl = new StackLayout() { Orientation = StackOrientation.Horizontal };
var symbol = new SymbolDisplay { WidthRequest = 40, HeightRequest = 40, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, 5, 0) };
symbol.SetBinding(SymbolDisplay.SymbolProperty, $"{nameof(LegendEntry.Content)}.{nameof(LegendInfo.Symbol)}");
symbol.SetBinding(SymbolDisplay.SymbolProperty, static (LegendEntry entry) => ((LegendInfo)entry.Content).Symbol);
sl.Children.Add(symbol);
var nameLabel = new Label { FontSize = 12, VerticalOptions = LayoutOptions.Center };
nameLabel.SetBinding(Label.TextProperty, $"{nameof(LegendEntry.Content)}.{nameof(LegendInfo.Name)}");
nameLabel.SetBinding(Label.TextProperty, static (LegendEntry entry) => ((LegendInfo)entry.Content).Name);
sl.Children.Add(nameLabel);
return sl;
});
Expand Down
9 changes: 3 additions & 6 deletions src/Toolkit/Toolkit.Maui/OverviewMap/OverviewMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Microsoft.Maui.Controls.Internals;
using System.Diagnostics.CodeAnalysis;
using Map = Esri.ArcGISRuntime.Mapping.Map;

namespace Esri.ArcGISRuntime.Toolkit.Maui;
Expand All @@ -32,8 +31,6 @@ public class OverviewMap : TemplatedView

private MapView? _overviewMapView;


[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.GeoModel.LoadStatus), "Esri.ArcGISRuntime.Mapping.GeoModel", "Esri.ArcGISRuntime")]
static OverviewMap()
{
DefaultControlTemplate = new ControlTemplate(() =>
Expand All @@ -50,15 +47,15 @@ static OverviewMap()
IsAttributionTextVisible = false
};
ActivityIndicator activity = new ActivityIndicator();
activity.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("Map.LoadStatus", converter: converter, converterParameter: "Loading", source : mapView));
activity.SetBinding(ActivityIndicator.IsRunningProperty, static (MapView mapView) => mapView.Map?.LoadStatus, converter: converter, converterParameter: "Loading", source: mapView);
root.Add(activity);
Label label = new Label()
{
TextColor = Colors.Black, Text = "Map failed to load. Did you forget an API key?"
};
label.SetBinding(VisualElement.IsVisibleProperty, new Binding("Map.LoadStatus", converter: converter, converterParameter: "FailedToLoad", source: mapView));
label.SetBinding(VisualElement.IsVisibleProperty, static (MapView mapView) => mapView.Map?.LoadStatus, converter: converter, converterParameter: "FailedToLoad", source: mapView);
root.Add(label);
mapView.SetBinding(VisualElement.IsVisibleProperty, new Binding("Map.LoadStatus", converter: converter, converterParameter: "Loaded", source: mapView));
mapView.SetBinding(VisualElement.IsVisibleProperty, static (MapView mapView) => mapView.Map?.LoadStatus, converter: converter, converterParameter: "Loaded", source: mapView);
root.Add(mapView);
INameScope nameScope = new NameScope();
NameScope.SetNameScope(rootFrame, nameScope);
Expand Down
18 changes: 9 additions & 9 deletions src/Toolkit/Toolkit.Maui/SearchView/SearchView.Appearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static SearchView()
containingGrid.SetAppThemeColor(Grid.BackgroundColorProperty, Color.FromArgb("#4e4e4e"), Color.FromArgb("#151515"));

Label textLabel = new Label();
textLabel.SetBinding(Label.TextProperty, "Key.DisplayName");
textLabel.SetBinding(Label.TextProperty, static (IGrouping<ISearchSource, SearchSuggestion> group) => group.Key.DisplayName);
textLabel.Margin = new Thickness(4);
textLabel.TextColor = Colors.White;
textLabel.FontSize = 14;
Expand All @@ -79,21 +79,21 @@ static SearchView()
textStack.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

Image imageView = new Image();
imageView.SetBinding(Image.SourceProperty, nameof(SearchSuggestion.IsCollection), converter: CollectionIconConverter);
imageView.SetBinding(Image.SourceProperty, static (SearchSuggestion suggestion) => suggestion.IsCollection, converter: CollectionIconConverter);
imageView.WidthRequest = 16;
imageView.HeightRequest = 16;
imageView.Margin = new Thickness(4);
imageView.VerticalOptions = LayoutOptions.Center;

Label titleLabel = new Label();
titleLabel.SetBinding(Label.TextProperty, nameof(SearchSuggestion.DisplayTitle));
titleLabel.SetBinding(Label.TextProperty, static (SearchSuggestion suggestion) => suggestion.DisplayTitle);
titleLabel.VerticalOptions = LayoutOptions.End;
titleLabel.VerticalTextAlignment = TextAlignment.End;
titleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb(FOREGROUND_LIGHT), Color.FromArgb(FOREGROUND_DARK));

Label subtitleLabel = new Label();
subtitleLabel.SetBinding(Label.TextProperty, nameof(SearchSuggestion.DisplaySubtitle));
subtitleLabel.SetBinding(Label.IsVisibleProperty, nameof(SearchSuggestion.DisplaySubtitle), converter: EmptyStringConverter);
subtitleLabel.SetBinding(Label.TextProperty, static (SearchSuggestion suggestion) => suggestion.DisplaySubtitle);
subtitleLabel.SetBinding(Label.IsVisibleProperty, static (SearchSuggestion suggestion) => suggestion.DisplaySubtitle, converter: EmptyStringConverter);
subtitleLabel.VerticalOptions = LayoutOptions.Start;
subtitleLabel.VerticalTextAlignment = TextAlignment.Start;
subtitleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb(FOREGROUND_LIGHT), Color.FromArgb(FOREGROUND_DARK));
Expand Down Expand Up @@ -128,22 +128,22 @@ static SearchView()
textStack.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

Image imageView = new Image();
imageView.SetBinding(Image.SourceProperty, nameof(SearchResult.MarkerImageData), converter: ImageSourceConverter);
imageView.SetBinding(Image.SourceProperty, static (SearchResult result) => result.MarkerImageData, converter: ImageSourceConverter);
imageView.WidthRequest = 24;
imageView.HeightRequest = 24;
imageView.Margin = new Thickness(4);
imageView.VerticalOptions = LayoutOptions.Center;

Label titleLabel = new Label();
titleLabel.SetBinding(Label.TextProperty, nameof(SearchResult.DisplayTitle));
titleLabel.SetBinding(Label.TextProperty, static (SearchResult result) => result.DisplayTitle);
titleLabel.FontAttributes = FontAttributes.Bold;
titleLabel.VerticalOptions = LayoutOptions.End;
titleLabel.VerticalTextAlignment = TextAlignment.End;
titleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb(FOREGROUND_LIGHT), Color.FromArgb(FOREGROUND_DARK));

Label subtitleLabel = new Label();
subtitleLabel.SetBinding(Label.TextProperty, nameof(SearchResult.DisplaySubtitle));
subtitleLabel.SetBinding(Label.IsVisibleProperty, nameof(SearchResult.DisplaySubtitle), converter: EmptyStringConverter);
subtitleLabel.SetBinding(Label.TextProperty, static (SearchResult result) => result.DisplaySubtitle);
subtitleLabel.SetBinding(Label.IsVisibleProperty, static (SearchResult result) => result.DisplaySubtitle, converter: EmptyStringConverter);
subtitleLabel.VerticalOptions = LayoutOptions.Start;
subtitleLabel.VerticalTextAlignment = TextAlignment.Start;
subtitleLabel.SetAppThemeColor(Label.TextColorProperty, Color.FromArgb(FOREGROUND_LIGHT), Color.FromArgb(FOREGROUND_DARK));
Expand Down
Loading
Loading