slider convention

Topics: Conventions
May 1, 2012 at 4:44 PM

how to set up a convention for a slider in wp7 ?


I tried:         

 ConventionManager.AddElementConvention<Slider>(Slider.ValueProperty, "Value", "ValueChanged");

In the model storage :

 Property(x => x.SliderValue)

In xaml:



<Slider Name="SilderValue"

In viewmodel:

  double sliderVal = 40;
        public double SliderValue
            get { return sliderVal; }
                sliderVal = value;


I does not even get the intial value (40) !

What's wrong /missing ?

May 1, 2012 at 5:35 PM
Edited May 2, 2012 at 3:41 AM

what are the contents of your Refresh() method?  If this is the Refresh() method found in CM it isn't enough you have to throw a notification to get the value to update on the view, inside of your property setter...


You also don't need to add the convention since it is already baked into the assembly.  It is one of the conventions already added.

Also you might want to have Logger (ref: gamelibrary sample code), to display the runtime bindings and conventions being applied as you run your app.

May 2, 2012 at 9:59 AM

Found the error: a typo:   Silder vs  Slider...

- The Slider convention is not already baked into the WP7 version of CM (without adding it manually it does not bind)  !

- THe Refresh() call from CM  seems to be enough: value updated, restored. But thanks for the hint: NotifyOfPropertyChanged(()=>SliderValue); may be more appropriate because it only updates the single prop.


May 2, 2012 at 7:36 PM

yep my bad on the convention reading thru the source it isn't in there... at any rate, the typo has part of the problem solved...