Click here to Skip to main content
15,887,214 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF Rotary Button Control Pin
Kevin Marois13-May-15 3:47
professionalKevin Marois13-May-15 3:47 
GeneralRe: WPF Rotary Button Control Pin
Kenneth Haugland13-May-15 4:07
mvaKenneth Haugland13-May-15 4:07 
GeneralRe: WPF Rotary Button Control Pin
Kevin Marois13-May-15 4:08
professionalKevin Marois13-May-15 4:08 
GeneralRe: WPF Rotary Button Control Pin
Kenneth Haugland13-May-15 4:11
mvaKenneth Haugland13-May-15 4:11 
GeneralRe: WPF Rotary Button Control Pin
Kevin Marois13-May-15 4:12
professionalKevin Marois13-May-15 4:12 
NewsNeed A WPF Joystick Type Control Pin
Kevin Marois12-May-15 8:06
professionalKevin Marois12-May-15 8:06 
AnswerRe: Need A WPF Joystick Type Control Pin
Afzaal Ahmad Zeeshan12-May-15 8:18
professionalAfzaal Ahmad Zeeshan12-May-15 8:18 
QuestionHow to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Bernhard Hiller12-May-15 2:29
Bernhard Hiller12-May-15 2:29 
I created a WPF (.Net 4) UserControl containing some ComboBoxes and a TextBox. In XAML, some ValidationRules are bound to the TextBox. If the TextBox contains invalid data, a red frame is shown, and the tooltip is set to the error description. Works well.
Next, I placed two instances of that UserControl on a form, and added a button. In XAML, the button is connected to a RelayCommand of the ViewModel. Now I want the button to be enabled only when both of the UserControls contain valid data only.
Not a problem, I thought, let me use a strategy which works elsewhere. I added a trigger:
HTML
<Button Content="_OK" ... Command="{Binding Path=OKCommand}">
    <Button.Style>
        <Style TargetType="{x:Type Button}">
            <Setter Property="IsEnabled" Value="false" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding ElementName=cascadingComboFrom, Path=(Validation.HasError)}" Value="false" />
                        <Condition Binding="{Binding ElementName=cascadingComboTo, Path=(Validation.HasError)}" Value="false" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="true" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </Button.Style>
</Button>
But there is a catch: Validation.HasError is always false for the UserControls - the Validation failed for an element inside the UserControl, not for the UserControl proper.
I know that I can register the Click event of the button, check the validity there using the method shown in http://stackoverflow.com/questions/127477/detecting-wpf-validation-errors[^], and prevent the execution of the RelayCommand by setting the Handled property of the RoutedEventArgs to true. But that looks more like WTF than WPF.
What do you suggest? How can I retrieve the Validation Errors of the UserControl's children? Or how can I get them in the RelayCommand's CanExecute method? Or some other tricks?
AnswerRe: How to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Pete O'Hanlon12-May-15 3:07
mvePete O'Hanlon12-May-15 3:07 
GeneralRe: How to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Bernhard Hiller12-May-15 3:54
Bernhard Hiller12-May-15 3:54 
GeneralRe: How to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Pete O'Hanlon12-May-15 3:58
mvePete O'Hanlon12-May-15 3:58 
GeneralRe: How to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Bernhard Hiller12-May-15 23:45
Bernhard Hiller12-May-15 23:45 
GeneralRe: How to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Pete O'Hanlon12-May-15 23:49
mvePete O'Hanlon12-May-15 23:49 
AnswerRe: How to forward Validation Errors from elements of a UserControl to the UserControl proper Pin
Bernhard Hiller12-May-15 23:52
Bernhard Hiller12-May-15 23:52 
QuestionWPF UserControl In WinForms Problem Pin
Kevin Marois7-May-15 13:20
professionalKevin Marois7-May-15 13:20 
QuestionConvert This To WPF Pin
Kevin Marois6-May-15 13:44
professionalKevin Marois6-May-15 13:44 
AnswerRe: Convert This To WPF Pin
Pete O'Hanlon6-May-15 18:37
mvePete O'Hanlon6-May-15 18:37 
QuestionScrolling Timescale Design Pin
Kevin Marois22-Apr-15 8:21
professionalKevin Marois22-Apr-15 8:21 
AnswerRe: Scrolling Timescale Design Pin
Mycroft Holmes22-Apr-15 14:27
professionalMycroft Holmes22-Apr-15 14:27 
QuestionWPF Timer Threading Exception Pin
Kevin Marois22-Apr-15 6:25
professionalKevin Marois22-Apr-15 6:25 
QuestionProper way to do MouseDoubleClick in MVVM Pin
David Ceder13-Apr-15 3:17
David Ceder13-Apr-15 3:17 
AnswerRe: Proper way to do MouseDoubleClick in MVVM Pin
Mycroft Holmes13-Apr-15 14:34
professionalMycroft Holmes13-Apr-15 14:34 
AnswerRe: Proper way to do MouseDoubleClick in MVVM Pin
SledgeHammer0114-Apr-15 5:02
SledgeHammer0114-Apr-15 5:02 
AnswerRe: Proper way to do MouseDoubleClick in MVVM Pin
Pete O'Hanlon14-Apr-15 6:09
mvePete O'Hanlon14-Apr-15 6:09 
QuestionHow can we change date in datepicker on selecting different country culture in combo box in MVVM? Pin
Member 1142836713-Apr-15 0:05
Member 1142836713-Apr-15 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.