Bonjour/Bonsoir
Je viens de regarder pas mal de tutoriel sur internet mais rien à faire (plein = env 10) je bloque sur le binding de sélection.
Voici le code actuel que j'ai.
<ComboBox Height="30" HorizontalAlignment="Left" Margin="534,39,0,0" Name="comboBox1" VerticalAlignment="Top" Width="170" SelectionChanged="comboBox1_SelectionChanged" SelectedItem="{Binding SelectedPath, Mode=OneWay}"/>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| public partial class Form : UserControl, INotifyPropertyChanged
{
public Form(Main main)
{
InitializeComponent();
this.comboBox1.ItemsSource = Data.DataBot.ListTypeAction(); //Item source équivaut à une List<String> Aucun soucis ils s'affichent tous dans la comboBox
}
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MessageBox.Show(this.SelectedPath);
}
private string selectedPath;
public string SelectedPath
{
get
{
return selectedPath;
}
set
{
if(value != null)
selectedPath = value;
OnPropertyChanged("SelectedPath");
}
}
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
} |
J'ai inséré un événement pour voir si la propriété change bien ou non. Et le truc c'est que c'est complétement vide.
Donc si vous avez une astuce ou si vous pouvez me corriger mon code. (je suis preneur de tous conseils et critique faut pas hésiter à en balancer)
Merci.
Partager