PropertyDefinition with RadNummericUpdown binding

2 posts, 0 answers
  1. Gilbert van Veen
    Gilbert van Veen avatar
    74 posts
    Member since:
    Oct 2009

    Posted 02 Jul 2015 Link to this post


    I have an Observerable collection with objects. One of the properties is the Location information (RadMap info) of a hotspot.

    The correct data is shown in the UpDown control but when I change the value (Up/Down arrows) the bound object (the location propery) is not changing?

    The collection has INotifyChanged etc. but it isn't fired?

    The XAML looks like this:

    <telerik:PropertyDefinition Binding="{Binding Location.Latitude, Mode=TwoWay}" DisplayName="Latitude" Description="Location latitude" GroupName="Location" IsReadOnly="False" IsExpanded="True">
    <telerik:RadNumericUpDown Value="{Binding Location.Latitude, Mode=TwoWay}" NumberDecimalDigits="12" Minimum="-99999" Maximum="9999" NumberDecimalSeparator="." />

     Other fields of the object, f.i. the name of the hotspot is changing correctly.





  2. Martin Ivanov
    Martin Ivanov avatar
    2420 posts

    Posted 07 Jul 2015 Link to this post

    Hi Gilbert,

    The binding of the Latitude and Longitude properties doesn't work because the Location object that expose them is a struct which means that you cannot set them directly. Moreover Location doesn't implement the INotifyPropertyChanged interface which means that the UI cannot listen for changes in its properties. 

    In order to achieve the desired result you can expose Latitude and Longitude properties in the business object' class which is set as a data context of the hot spot. Then in the properties' setters you can update the Location property. Here is an example:
    public class MyObject : ViewModelBase
        private Location location
        public Location Location
            get { return this.location; }
                if (this.location != value)
                    this.location = value;
        private double latitude
        public double Latitude
            get { return this.latitude; }
                if (this.latitude != value)
                    this.latitude = value;
                    this.Location = new Location(this.latitude, this.Location.Longitude);
    Please give this approach a try and let me know if it works for you. If not, can you please send me an isolated project that demonstrates your implementation. This will help me in better understanding your scenario and think of a more suitable approach for your case.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top