Esri / arcgis-maps-sdk-dotnet-toolkit

Toolkit for ArcGIS Maps SDK for .NET
https://esri.github.io/arcgis-maps-sdk-dotnet-toolkit/
Apache License 2.0
211 stars 121 forks source link

Improve MVVM support for some Toolkit controls #498

Open nCastle1 opened 1 year ago

nCastle1 commented 1 year ago

Search and FloorFilter both depend on setting a DataContext in the constructor. This doesn't work if there is an externally-set DataContext, which is quite common in MVVM scenarios.

The quick fix is to add a wrapping FrameworkElement in the control template, and explicitly set the DataContext to {x:Null}, then set the DataContext on the child.

dotMorten commented 1 year ago

Custom controls should not set the datacontext anywhere, but instead use TemplateBinding.