I am trying to set the value of a numeric up down control based on the value of a picker. I would like to set the value of the numeric up down after the selected item in the picker is changed. How can I achieve this?
Thank you in advance.
<forms:Grid x:Name="grid" VerticalOptions="FillAndExpand">
<datagrid:SfDataGrid x:Name="dataGrid"
AutoGenerateColumns="False"
AllowPullToRefresh="True"
ColumnSizer="LastColumnFill"
ItemsSource="{Binding Products}"
RowHeight="150"
VerticalOptions="FillAndExpand">
<datagrid:SfDataGrid.Columns>
<datagrid:GridTemplateColumn HeaderCellTextSize="16"
HeaderFontAttribute="Bold"
HeaderText="Products"
LineBreakMode="TailTruncation"
MappingName="Id">
<datagrid:GridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid ColumnSpacing="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="productGrid"
Grid.Row="0"
Grid.Column="0"
RowSpacing="0"
Padding="5"
BackgroundColor="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label x:Name="descriptionLabel"
FontAttributes="Bold"
FontSize="16"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
LineBreakMode="TailTruncation"
Text="{Binding Description}"
TextColor="Black"
BackgroundColor="Transparent">
</Label>
<Picker x:Name="variationPicker"
Title="Variation"
ItemsSource="{Binding ProductVariations}"
ItemDisplayBinding="{Binding Description}"
IsEnabled="{Binding ProductVariations.Count}"
SelectedIndexChanged="variationPicker_SelectedIndexChanged"
Grid.Row="1"
Grid.Column="0" />
<numericupdown:SfNumericUpDown x:Name="requiredQty"
Value="{Binding Quantity}"
FontAttribute="Bold"
FontSize="25"
Maximum="999999.999"
Minimum="0"
TextAlignment="Center"
TextColor="Black"
SpinButtonAlignment="Both"
StepValue="{Binding NetQuantity, Converter={StaticResource sCNumericUpDownQuantityStepValue}}"
MaximumDecimalDigits="{Binding Weighed, Converter={StaticResource sCNumericUpDownQuantityDecimalPlaces}}"
FormatString="{Binding Weighed, Converter={StaticResource sCNumericUpDownQuantityStringformat}}"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"/>
<Button x:Name="addProduct"
Grid.Row="3"
Grid.Column="0"
Grid.ColumnSpan="2"
Text="Add"
BackgroundColor="{StaticResource appTertiaryColour}"
Pressed="addProduct_Pressed"/>
</Grid>
</Grid>
</DataTemplate>
</datagrid:GridTemplateColumn.CellTemplate>
</datagrid:GridTemplateColumn>
</datagrid:SfDataGrid.Columns>
</datagrid:SfDataGrid>
</forms:Grid>
private void variationPicker_SelectedIndexChanged(object sender, EventArgs e)
{ var requiredQty = ((((sender as Picker).Parent as Grid).Parent as Grid).Parent as GridCell).Content.FindByName("requiredQty"); if ((sender as Picker).SelectedItem == "India") { ((requiredQty as SfNumericUpDown).BindingContext as Data).No_1 = 3; } } |
Thank you, that worked perfectly.