Click here to Skip to main content
16,007,687 members
Home / Discussions / WPF
   

WPF

 
QuestionWPF ListBoxItem Style Not Working Pin
Kevin Marois26-May-15 9:48
professionalKevin Marois26-May-15 9:48 
QuestionPost Publish Actions Pin
Mycroft Holmes21-May-15 16:32
professionalMycroft Holmes21-May-15 16:32 
QuestionRe: Post Publish Actions Pin
Kenneth Haugland22-May-15 10:08
mvaKenneth Haugland22-May-15 10:08 
AnswerRe: Post Publish Actions Pin
Mycroft Holmes22-May-15 13:42
professionalMycroft Holmes22-May-15 13:42 
QuestionNeed Entity Framework Video Tutorial using WPF Pin
Ashfaque Hussain21-May-15 1:09
Ashfaque Hussain21-May-15 1:09 
QuestionRe: Need Entity Framework Video Tutorial using WPF Pin
Richard MacCutchan21-May-15 1:29
mveRichard MacCutchan21-May-15 1:29 
AnswerRe: Need Entity Framework Video Tutorial using WPF Pin
Ashfaque Hussain21-May-15 1:50
Ashfaque Hussain21-May-15 1:50 
SuggestionWPF App for Tablet Pin
Member 1160551220-May-15 23:50
Member 1160551220-May-15 23:50 
Questionwindow set fontsize question Pin
econy20-May-15 4:09
econy20-May-15 4:09 
AnswerRe: window set fontsize question Pin
Richard Deeming20-May-15 4:48
mveRichard Deeming20-May-15 4:48 
GeneralRe: window set fontsize question Pin
econy20-May-15 5:13
econy20-May-15 5:13 
QuestionTreeview with check box binding in silverlight Pin
Member 1151284413-May-15 23:02
Member 1151284413-May-15 23:02 
AnswerRe: Treeview with check box binding in silverlight Pin
Kenneth Haugland14-May-15 18:57
mvaKenneth Haugland14-May-15 18:57 
QuestionWPF Rotary Button Control Pin
Kevin Marois12-May-15 12:09
professionalKevin Marois12-May-15 12:09 
AnswerRe: WPF Rotary Button Control Pin
Richard Deeming13-May-15 1:23
mveRichard Deeming13-May-15 1:23 
AnswerRe: WPF Rotary Button Control Pin
Kenneth Haugland13-May-15 1:27
mvaKenneth Haugland13-May-15 1:27 
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 

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.