I am trying to perform some simple binding in a Windows Store app. Some controls e.g.
ToggleButton
bind fine, but when a
Slider
is bound, changes in the UI are not reflected in the bound object.
The data source is an
ObservableCollection<Film>
.
Film
has some properties including:
public bool Seen { get; set; }
public int Rating { get; set; }
The XAML is like (simplified for clarity):
<Page DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}">
<FlipView DataContext="{Binding Group}" ItemsSource="{Binding Source={StaticResource itemsViewSource}}">
<FlipView.ItemTemplate>
<DataTemplate>
<StackPanel>
<ToggleButton Content="Seen It" IsChecked="{Binding Seen, Mode=TwoWay}">
<Slider Value="{Binding Rating, Mode=TwoWay}" IsEnabled="{Binding Seen}" Etc="the usual properties set here.">
</StackPanel>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
</Page>
When the user interacts with the
ToggleButton
, the
Film
's Seen property is updated. The
Rating
property never changes. I have to manually updated the business object in code behind.
I have been googling all day. I couldn't find other examples of binding
Slider.Value
. Everyone is interested in binding it to the value of a
TextBox
.