<syncfusion:GridTemplateColumn Width="220"
VerticalAlignment="Center"
AllowSorting="False"
CellTemplateSelector="{StaticResource RuptureTemplateSelector}"
ColumnSizer="SizeToCells"
HeaderText="{CustomResource NewCommandePage_QuantitiesHeader}"
TextAlignment="Center"
/>
<SfInput:SfNumericUpDown syncfusion:FocusManagerHelper.FocusedElement="True"
LargeChange="{Binding Produit.QteMini}"
Maximum="{Binding Converter={StaticResource MaximumCommandeProduitConverter}, Mode=OneWay}"
Minimum="0"
SmallChange="{Binding Produit.QteMini}"
Style="{StaticResource IntNumericUpDown}"
Value="{Binding QuantiteCommandee, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
var rdr = (uiArticlesGrid.CellRenderers["Template"] as GridCellTemplateRenderer);
rdr.AllowRecycle = false;
rdr.IsEditable = true;
<Grid:GridTemplateColumn MappingName="EmployeeAge" Width="250">
<Grid:GridTemplateColumn.CellTemplate>
<DataTemplate>
<editors:SfNumericUpDown Grid:FocusManagerHelper.FocusedElement="True"
DataContext="{Binding}"
Minimum="0">
<i:Interaction.Behaviors>
<i:BehaviorCollection>
<local:GridBehavior/>
</i:BehaviorCollection>
</i:Interaction.Behaviors>
</editors:SfNumericUpDown>
</DataTemplate>
</Grid:GridTemplateColumn.CellTemplate>
</Grid:GridTemplateColumn>
public class GridBehavior : DependencyObject, IBehavior
{
SfNumericUpDown upDown;
public DependencyObject AssociatedObject
{
get
{
return upDown;
}
}
public void Attach(DependencyObject associatedObject)
{
upDown = associatedObject as SfNumericUpDown;
upDown.Loaded += UpDown_Loaded;
upDown.DataContextChanged += UpDown_DataContextChanged;
upDown.ValueChanged += UpDown_ValueChanged;
}
private void UpDown_ValueChanged(object sender, ValueChangedEventArgs e)
{
if (upDown.DataContext == null || isinsuspend)
return;
int updownval = 0;
if (upDown.Value != null)
int.TryParse(upDown.Value.ToString(), out updownval);
(upDown.DataContext as BusinessObjects).EmployeeAge = updownval;
}
bool isinsuspend = false;
private void UpDown_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
{
if (upDown.DataContext == null)
return;
isinsuspend = true;
var _maxval = (upDown.DataContext as BusinessObjects).Maximum;
var _val = (upDown.DataContext as BusinessObjects).EmployeeAge;
upDown.Maximum = _maxval;
upDown.Value = _val;
isinsuspend = false;
}
private void UpDown_Loaded(object sender, RoutedEventArgs e)
{
if (upDown.DataContext == null)
return;
isinsuspend = true;
var _maxval = (upDown.DataContext as BusinessObjects).Maximum;
var _val = (upDown.DataContext as BusinessObjects).EmployeeAge;
upDown.Maximum = _maxval;
upDown.Value = _val;
isinsuspend = false;
}
public void Detach()
{
upDown.Loaded -= UpDown_Loaded;
upDown.DataContextChanged -= UpDown_DataContextChanged;
upDown.ValueChanged -= UpDown_ValueChanged;
}
}
|