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>
|
<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> |
|
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; }
} |