We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

SfLinearGauge binding in a ListView

Thread ID:

Created:

Updated:

Platform:

Replies:

118868 Apr 17,2015 12:48 AM Apr 20,2015 09:31 AM Xamarin.Forms 3
loading
Tags: SfLinearGauge
Derrick Willer
Asked On April 17, 2015 12:48 AM

I am trying to include a LinearGauge inside a ListView DataTemplate.  I cannot figure out how to bind the LinearRange StartValue and EndValue.  If I specify a BindingContext per LinearRange, I can get the values set to an initial value in the ViewModel.  But any subsequent changes aren't displayed.

Here is the Xaml within a ViewCell:

<syncfusion:SfLinearGauge BackgroundColor="White" Orientation="OrientationHorizontal" HeightRequest="20" WidthRequest="200" >
                                            <syncfusion:SfLinearGauge.BindingContext>
                                                 <viewModels:ServerViewModel />
                                            </syncfusion:SfLinearGauge.BindingContext>
                                            <syncfusion:SfLinearGauge.Scales>
                                                <syncfusion:LinearScale MinimumValue="0" MaximumValue="100" Interval="20" ScaleBarLength="100"  
                                                    ScaleBarColor="White" LabelColor="White" MinorTicksPerInterval="1" ScaleBarSize="13"
                                                    ScalePosition="Forward" ShowRim="false" ShowLabels="false" >
                                                    <syncfusion:LinearScale.Ranges>
                                                        <syncfusion:LinearRange StartValue="0" EndValue="{Binding Text}" Color="#00853f" StartWidth="10"
                                                                                EndWidth="10" Offset="-0.17" >
                                                                                <syncfusion:LinearRange.BindingContext>
                                                                                     <viewModels:ServerViewModel x:Name="startViewModel" />
                                                                                </syncfusion:LinearRange.BindingContext>
                                                                                </syncfusion:LinearRange>
                                                        <syncfusion:LinearRange StartValue="{Binding TestValue}" EndValue="100" Color="#9fa0a1" StartWidth="10"
                                                                                EndWidth="10" Offset="-0.17">
                                                                                <syncfusion:LinearRange.BindingContext>
                                                                                     <viewModels:ServerViewModel x:Name="endViewModel" />
                                                                                </syncfusion:LinearRange.BindingContext>
                                                                                </syncfusion:LinearRange>
                                                    </syncfusion:LinearScale.Ranges>
                                                </syncfusion:LinearScale>
                                            </syncfusion:SfLinearGauge.Scales>
                                        </syncfusion:SfLinearGauge>
  

Here is the ViewModel property:
private double _value = 10;
        public double TestValue
        {
            set
            {
                if (_value != value)
                {
                    _value = value;
                    OnPropertyChanged();
                }
            }
            get
            {
                return _value;
            }
        }
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;  
        private void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName]string Membername = null)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                System.ComponentModel.PropertyChangedEventArgs propertyChangedEvent 
                = new System.ComponentModel.PropertyChangedEventArgs(Membername);
                handler(this, propertyChangedEvent);
            }
        }
 

How do you correctly bind the StartValue and EndValue?

Thanks! 

Paul Anderson S [Syncfusion]
Replied On April 17, 2015 09:03 AM

Hi Derrick,

Thank you for using syncfusion products.

We have tried to reproduce the reported problem based on the provided code snippet and we are able to reproduce the issue in LinearRange updating dynamically. We would like to ensure whether you wanted to change LinearRange or while changing Symbol/BarPointers,if you could update us the information,it will be conveninent for us to provide you a better solution.


Please let us know if you have any other queries.

Regards,
Paul Anderson

Derrick Willer
Replied On April 17, 2015 11:21 AM

How do you bind a LinearRange StartValue and EndValues then? I am able to bind them to a ViewModel, but only the initial VM property value gets set.  Any subsequent changes to the VM property are not reflected.  Basically, how do you include a LinearGraph that is bindable within a ListView data template.  I guess I could create my own data repeater in code behind by running a foreach loop over the ItemSource collection and then add to a StackLayout.  But I would really like to be able to use MVVM / XAML binding for this.

How do you set the BindingContext for the LinearRange within a Data Template?

Thanks!

Paul Anderson S [Syncfusion]
Replied On April 20, 2015 09:31 AM

Hi Derrick,

We were able to reproduce the issue and have logged defect report regarding this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let me know if you have any questions.

Regards,
Paul Anderson

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;