Command Linking To Value Changed

I'm having trouble getting a event to behavior command linked to when my SfNumericUpDown value changes.

I have an SfNumericUpDown within a ListView and I'm having a difficult time interpreting which item in the list I'm working with because I can't figure out which EventName into my EventToCommandBehavior.

Any ideas?

Normally I can do something like this:

<Entry.Behaviors>
     <helper:EventToCommandBehavior
            EventName="ThisWouldBeTheEventForValueChanged"
            Command="{Binding DoSomethingCommand}"
            CommandParameter="{Binding Source={x:Reference ThisIsTheListForReference}}"/>
 </Entry.Behaviors>


1 Reply 1 reply marked as answer

RS Ramya Soundar Rajan Syncfusion Team July 27, 2020 02:13 PM UTC

Hi Matthew, 
 
Greetings from Syncfusion. 
 
We have achieved your requirement with EventToCommandBehavior for SfNumericUpDown ValueChanged event. Added the SfNumericUpDown control inside the ListView as like in the below code snippet. 
 
[XAML] 
        <ListView x:Name="listView" ItemsSource="{Binding ItemCollection }" ItemSelected="ListView_ItemSelected" ItemTapped="ListView_ItemTapped"> 
            <ListView.ItemTemplate> 
                <DataTemplate> 
                    <ViewCell> 
                        <numeric:SfNumericUpDown x:Name="numericUpDown"  Value="{Binding NumericValue}"> 
                            <numeric:SfNumericUpDown.Behaviors> 
                                <local:EventToCommandBehavior EventName="ValueChanged" Command="{Binding ValueChangedCommand}" CommandParameter="{x:Reference numericUpDown}"/> 
                            </numeric:SfNumericUpDown.Behaviors> 
                        </numeric:SfNumericUpDown> 
                    </ViewCell> 
                </DataTemplate> 
            </ListView.ItemTemplate> 
        </ListView> 
 
 
[C#] 
    public class ViewModel : BindableObject 
   
        public IList<Contacts> ItemCollection { get; private set; } 
        public ViewModel() 
       
            ItemCollection = new List<Contacts>(); 
            for (int i = 1; i < 10; i++) 
           
                ItemCollection.Add(new Contacts() { NumericValue = i }); 
           
       
   
 
    public class Contacts 
    { 
        public Contacts() 
        { 
            ValueChangedCommand = new Command(NumericValueChangedEvent); 
        } 
        private void NumericValueChangedEvent(object args) 
        { 
        } 
        private int numericValue; 
        public int NumericValue 
        { 
            get { return numericValue; } 
            set { numericValue = value; } 
        } 
        public ICommand ValueChangedCommand { get; private set; } 
    } 
 
 
Please let us know if you have any concerns. 
 
Regards, 
Ramya S 


Marked as answer
Loader.
Up arrow icon