Reputation: 21
I have a model with properties:
/// <summary>
/// List of available map modes
/// </summary>
public Array MapModes { get; private set; }
/// <summary>
/// The current cartographic mode of the map
/// </summary>
public MapCartographicMode MapMode
{
get { return _mapMode; }
set
{
if (value == _mapMode) return;
_mapMode = value;
OnPropertyChanged();
}
}
/// <summary>
/// List of available map color modes
/// </summary>
public Array MapColorModes { get; private set; }
//The current color mode of the map
public MapColorMode MapColorMode
{
get { return _mapColorMode; }
set
{
if (value == _mapColorMode) return;
_mapColorMode = value;
OnPropertyChanged();
}
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
And My XAML looks like this:
<maps:Map x:Name="MainMap"
Height="{Binding MapHeight}"
ColorMode="{Binding MapColorMode, Converter={StaticResource MapTestConverter}}">
The properties are updated on another page.
<toolkit:ListPicker Header="Map mode"
ItemsSource="{Binding MapModes}"
SelectedItem="{Binding Path=MapMode, Mode=TwoWay}"/>
<toolkit:ListPicker Header="Map color mode"
ItemsSource="{Binding MapColorModes}"
SelectedItem="{Binding Path=MapColorMode, Mode=TwoWay}"/>
Now the binding of the ListPickers works fine the value in the model always represents what was last picked here.
The Map binding also works, it gets the initial value and also updates the first time I change a property.
BUT that's it. after the first property change it refuses to update. (The dummy IValueConverter isn't called).
The model still nicely raises Property changed events, and the property has the correct value in the model (manually assigning it for example at page load works flawlessly)
Since it seems the Binding is getting "broken" I tried recreating it each time the property was updated
Binding b = new Binding("MapMode");
BindingOperations.SetBinding(MainMap, Map.CartographicModeProperty, b);
This works. I am beginning to think there is a bug or something in the wp8 map implementation. (Or I may just miss something completely obvious^^)
Upvotes: 1
Views: 625
Reputation: 69
I had the same. The solution is to provide Mode=TwoWay to the bindings. I have no idea why that works, but it seems. On this blog I have seen exactly this solution: http://dotnetbyexample.blogspot.ch/2012/10/introducing-new-windows-8-map-control.html
Upvotes: 1