or
<Grid Width="900" > <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <telerik:RadGridView ItemsSource="{Binding ListIntervention}" IsSynchronizedWithCurrentItem="True" AutoGenerateColumns="False" ShowInsertRow="True" > <telerik:RadGridView.Columns> <telerik:GridViewComboBoxColumn Header="Objet intervention" Width="300" ItemsSource="{Binding ListObjet}" DataMemberBinding="{Binding ObjetId, Mode=TwoWay}" DisplayMemberPath="Libelle" SelectedValueMemberPath="Id" /> <telerik:GridViewComboBoxColumn Header="Sous catégorie" Width="300" ItemsSource="{Binding ListSousCategorie}" DataMemberBinding="{Binding SsCategorieId, Mode=TwoWay}" DisplayMemberPath="Libelle" SelectedValueMemberPath="Id" /> <telerik:GridViewComboBoxColumn Header="Catégorie" Width="*" ItemsSource="{Binding ListCategorie}" DataMemberBinding="{Binding CategorieId, Mode=TwoWay}" DisplayMemberPath="Libelle" SelectedValueMemberPath="Id" /> </telerik:RadGridView.Columns> </telerik:RadGridView> </Grid>public class GestionAccueilViewModel : ActiveAwareViewModelBase{ #region Fields private readonly ITroncCommunService _troncCommunService; private readonly IMessageBoxService _messageBoxService; #endregion #region Ctor public GestionAccueilViewModel(ITroncCommunService troncCommunService, IMessageBoxService messageBoxService) { _troncCommunService=troncCommunService; _messageBoxService=messageBoxService; // Init. ListSousCategorie=new ObservableCollection<TypeBouchonObjet>(); ListCategorie=new ObservableCollection<TypeBouchonObjet>(); ListObjet = new ObservableCollection<TypeBouchonObjet>(); ListIntervention=new ObservableCollection<TypeBouchonIntervention>(); // Mocks ListObjet.Add(new TypeBouchonObjet() { Id=1, Libelle="Date de paiement des prestations" }); ListObjet.Add(new TypeBouchonObjet() { Id=2, Libelle="Autre objet" }); ListSousCategorie.Add(new TypeBouchonObjet() { Id=1, Libelle="Logement nature" }); ListSousCategorie.Add(new TypeBouchonObjet() { Id=2, Libelle="Autre sous-catégorie" }); ListCategorie.Add(new TypeBouchonObjet() { Id=1, Libelle="AVNAT" }); ListCategorie.Add(new TypeBouchonObjet() { Id=2, Libelle="Autre categorie" }); ListIntervention.Add(new TypeBouchonIntervention() { ObjetId=1, CategorieId=1, SsCategorieId=1 }); ListIntervention.Add(new TypeBouchonIntervention() { ObjetId=2, CategorieId=2, SsCategorieId=2 }); } #endregion #region Listes private ObservableCollection<TypeBouchonIntervention> _listIntervention; public ObservableCollection<TypeBouchonIntervention> ListIntervention { get { return _listIntervention; } set { SetValueAndRaiseEventIfPropertyChanged<ObservableCollection<TypeBouchonIntervention>>("ListIntervention", ref _listIntervention, ref value); } } // Test RadGridView public ObservableCollection<TypeBouchonObjet> ListObjet { get; set; } public ObservableCollection<TypeBouchonObjet> ListCategorie { get; set; } public ObservableCollection<TypeBouchonObjet> ListSousCategorie { get; set; } #endregion #region Commands /// <summary> /// Valide l'accueil en cours /// </summary> public ICommand ValiderAccueilCommand { get; set; } /// <summary> /// RAZ de l'accueil en cours /// </summary> public ICommand AnnulerAccueilCommand { get; set; } /// <summary> /// Crée un nouvel écran d'accueil /// </summary> public ICommand NouvelAccueilCommand { get; set; } /// <summary> /// Recherche d'une personne via l'écran d'accueil /// </summary> public ICommand RechercherPersonneAccueilCommand { get; set; } #endregionpublic class TypeBouchon { public string Code { get; set; } public string Libelle{ get; set; } } public class TypeBouchonIntervention { public int ObjetId { get; set; } public int SsCategorieId { get; set; } public int CategorieId { get; set; } }private
void RadGridViewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (radGridView.CurrentItem == null) return;
//
// some code
//
}
here the ( radGridView.CurrentItem ) returns null at times, even though the current item details could be seen while debugging.
