Click here to Skip to main content
15,399,440 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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:
C#
public bool Seen { get; set; } // Actually INotifyPropertyChanged is implemented
public int Rating { get; set; } // on both.

The XAML is like (simplified for clarity):
XAML
<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.
Posted
Updated 8-Jun-14 9:52am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900