Hello,
I have a telerik radGridView that itemsSource binding to my list observableCollection<Class1>
i have a button that on her click event i i add a new item to my list, i want focus the new item first cell,
so i want do it with the event AddingNewDataItem but it not camming to this event.
heer is my xaml code:
<Grid>
<telerik:RadGridView x:Name="PricingGrid" ItemsSource="{Binding}"
CanUserInsertRows="True" ShowInsertRow="True"
AddingNewDataItem="PricingGrid_AddingNewDataItem"
RowEditEnded="PricingGrid_RowEditEnded" >
</telerik:RadGridView>
<Button Content="Button" HorizontalAlignment="Left" Height="61" Margin="269,237,0,0" VerticalAlignment="Top" Width="176" Click="Button_Click"/>
</Grid>
heer is my C# code:
public partial class MainWindow : Window
{
public CollectionViewSource Source { get; set; }
public ObservableCollection<MyClass> list = new ObservableCollection<MyClass>();
public MainWindow()
{
InitializeComponent();
this.Source = new CollectionViewSource();
//var list = new ObservableCollection<MyClass>();
for (int i = 0; i < 10; i++)
{
var item = new MyClass { MyProp2 = i, MyProperty = i * 10 };
list.Add(item);
}
Source.Source = list;
this.DataContext = Source.View;
}
private void PricingGrid_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
{
if (e.EditOperationType == Telerik.Windows.Controls.GridView.GridViewEditOperationType.Insert)
{
this.DataContext = Source.View.OfType<MyClass>().OrderBy(c => c.MyProperty);
Source.Source = this.DataContext;
PricingGrid.SelectedItem = e.NewData;
PricingGrid.ScrollIntoView(e.NewData);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
list.Add(new MyClass { MyProp2 = 4, MyProperty = 40 });
}
private void PricingGrid_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
}
}
public class MyClass
{
public int MyProperty { get; set; }
public int MyProp2 { get; set; }
}
thank for help!
miri.