my problem is in my MVVM system.
I have a XAML view and a ViewModel.
When I change the value of my ComboBox, the setter of the property of the selected value of the combobox is not set (ie the debugger do not pass in it), and so the NotifyPropertyChanged is not raised, and so my view is not refreshed.
Here is some code :
The view :
Code: Select all
...
<ComboBox Grid.Row="1" ItemsSource="{Binding ListOfCategories}" DisplayMemberPath="Libelle" SelectedValuePath="Code" SelectedValue="{Binding SelectedCategorie, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsCategorieEnabled, Mode=TwoWay}" />
...
the code-behind of the view :
Code: Select all
public partial class AskTextQuestionPage : Page
{
public AskTextQuestionPage()
{
InitializeComponent();
DataContext = new AskTextQuestionViewModel();
}
}
The ViewModel (the list is filled in the constructor of the class):
Code: Select all
class AskTextQuestionViewModel : ViewModelBase
{
...
private ObservableCollection<Categorie> _listOfCategories;
public ObservableCollection<Categorie> ListOfCategories
{
get
{
return _listOfCategories;
}
set
{
_listOfCategories = value;
}
}
public string SelectedCategorie
{
get
{
return _selectedCategorie;
}
set
{
_selectedCategorie = value;
NotifyPropertyChanged();
}
}
The ViewModelBase class :
Code: Select all
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
I think in pure XAML (I mean in a pure WPF app) it should work (not tested :s, it's the next step...), so should the problem come from the implementation of INotifyPropertyChanged in the beta ?
Thx for your reply.
ThibTib.