Bonjour tout le monde
Voici ma problématique :
j'ai une textbox ou j'ai mis un idataerror (StringEmpty et String déjà existant)
j'arrive parfaitement à l'afficher en temps normal mon problème se situe au moment de l'affichage, je ne voudrais l'afficher que lorsque je click sur mon bouton pour sauvegarder :
voici mon xaml de textbox et de bouton :
voici mon IdataError
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <TextBox Margin="10,4,0,4" Height="20" Width="200" VerticalContentAlignment="Center" Text="{Binding NomBatimentEnregistre, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" /> <Button Margin="10,0,0,0" x:Name="EnregistrerDeperdition" Command="{Binding EnregistrerDeperditionCommand}" VerticalAlignment="Center" HorizontalAlignment="Right" Height="20" Width="20" Background="{x:Null}" BorderThickness="0" ToolTip="Enregistrer local"> <StackPanel Orientation="Horizontal"> <Image Source="/Apeiron;component/Utils/Images/Ok.png" RenderOptions.BitmapScalingMode="HighQuality" Stretch="Uniform"/> </StackPanel> </Button>
j'ai essayé de faire un binding sur NotifyOnValidationError mais il me mets que cela n'est pas possible ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public string this[string propertyName] { get { string result = string.Empty; propertyName = propertyName ?? string.Empty; if (propertyName == string.Empty || propertyName == "NomBatimentEnregistre") { if (string.IsNullOrEmpty(this.NomBatimentEnregistre)) { result += "Veuillez rentrer un nom de bâtiment !" + Environment.NewLine; } else { var test = EnregistrementProvider.GetAll(); var count = test.Count(s => s.DonneeDeperdition.NomBatiment == NomBatimentEnregistre); if (count > 0) { result += "Ce nom de bâtiment existe déjà, veuillez en choisir un autre !" + Environment.NewLine; } } } return result.TrimEnd(); } }
Mon Icommand possède un paramètre cansave si pas d'erreur. mais comment faire apparaître juste mon notifyerror quand je click sur mon button
par un trigger ??
Partager