Hi,
ich habe eine ComboBox an die ValidationRules gebunden sind (Text darf nicht leer sein, Text muss eine MAC-Adresse sein).
Spoiler anzeigen
Den Button aktiviere ich per Style, sofern alles in Ordnung ist...
Spoiler anzeigen
Jetzt möchte dem Benutzer aber auch die Möglichkeit geben, per Enter-Taste die Methode aufzurufen... Dazu habe ich folgenden Code in der ComboBox hinzugefügt...
Kann mir jemand sagen wie ich prüfen kann, ob ein Fehler besteht und das ausführen der Funktion verhindern kann?
Sitze daran schon ein paar Tage und komme leider nicht weiter. Denn Button kann ich leider nicht auf
Wer mehr code sehen will:
View: github.com/BornToBeRoot/NETwor…ations/WakeOnLANView.xaml
View CS: github.com/BornToBeRoot/NETwor…ons/WakeOnLANView.xaml.cs
ViewModel: github.com/BornToBeRoot/NETwor…ons/WakeOnLanViewModel.cs
Danke für jede Hilfe
ich habe eine ComboBox an die ValidationRules gebunden sind (Text darf nicht leer sein, Text muss eine MAC-Adresse sein).
Quellcode
- <ComboBox.Text>
- <Binding Path="MACAddress" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
- <Binding.ValidationRules>
- <Validator:EmptyFieldValidator ValidatesOnTargetUpdated="True" />
- <Validator:MACAddressValidator ValidatesOnTargetUpdated="True"/>
- </Binding.ValidationRules>
- </Binding>
- </ComboBox.Text>
Den Button aktiviere ich per Style, sofern alles in Ordnung ist...
Quellcode
- <Button.Style>
- <Style TargetType="{x:Type Button}" BasedOn="{StaticResource ImageWithTextButton}" >
- <Setter Property="IsEnabled" Value="False" />
- <Style.Triggers>
- <MultiDataTrigger>
- <MultiDataTrigger.Conditions>
- <Condition Binding="{Binding Path=(Validation.HasError), ElementName=cbMACAddress}" Value="False"/>
- <Condition Binding="{Binding Path=(Validation.HasError), ElementName=txtBroadcast}" Value="False"/>
- <Condition Binding="{Binding Path=(Validation.HasError), ElementName=txtPort}" Value="False"/>
- </MultiDataTrigger.Conditions>
- <Setter Property="IsEnabled" Value="True" />
- </MultiDataTrigger>
- </Style.Triggers>
- </Style>
- </Button.Style>
Jetzt möchte dem Benutzer aber auch die Möglichkeit geben, per Enter-Taste die Methode aufzurufen... Dazu habe ich folgenden Code in der ComboBox hinzugefügt...
Kann mir jemand sagen wie ich prüfen kann, ob ein Fehler besteht und das ausführen der Funktion verhindern kann?
Sitze daran schon ein paar Tage und komme leider nicht weiter. Denn Button kann ich leider nicht auf
IsDefault="true"
setzen.Wer mehr code sehen will:
View: github.com/BornToBeRoot/NETwor…ations/WakeOnLANView.xaml
View CS: github.com/BornToBeRoot/NETwor…ons/WakeOnLANView.xaml.cs
ViewModel: github.com/BornToBeRoot/NETwor…ons/WakeOnLanViewModel.cs
Danke für jede Hilfe
NETworkManager - A powerful tool for managing networks and troubleshoot network problems!