Click here to Skip to main content
14,267,388 members

Silverlight / WPF

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 3:09
adminChris Maunder16-Jul-09 3:09 
PinnedHow to get an answer to your question PinPopular
Chris Maunder16-Jul-09 3:05
adminChris Maunder16-Jul-09 3:05 
QuestionWPF application displays differently in Windows 7 and Windows 10 Pin
Jakob Farian Krarup20hrs 11mins ago
memberJakob Farian Krarup20hrs 11mins ago 
QuestionWPF and Windows Forms at same time. Pin
michaelbarb15-Aug-19 5:12
membermichaelbarb15-Aug-19 5:12 
AnswerRe: WPF and Windows Forms at same time. Pin
Pete O'Hanlon15-Aug-19 5:39
protectorPete O'Hanlon15-Aug-19 5:39 
GeneralRe: WPF and Windows Forms at same time. Pin
michaelbarb15-Aug-19 6:15
membermichaelbarb15-Aug-19 6:15 
QuestionEnregistrer en RTF un RichTextBox / Save RTF RichTextBox Pin
dctc333-Aug-19 23:00
memberdctc333-Aug-19 23:00 
AnswerRe: Enregistrer en RTF un RichTextBox / Save RTF RichTextBox Pin
OriginalGriff3-Aug-19 23:05
protectorOriginalGriff3-Aug-19 23:05 
AnswerRe: Enregistrer en RTF un RichTextBox / Save RTF RichTextBox Pin
Gerry Schmitz4-Aug-19 6:51
mveGerry Schmitz4-Aug-19 6:51 
GeneralRe: Enregistrer en RTF un RichTextBox / Save RTF RichTextBox Pin
dctc335-Aug-19 23:54
memberdctc335-Aug-19 23:54 
GeneralRe: Enregistrer en RTF un RichTextBox / Save RTF RichTextBox Pin
Gerry Schmitz6-Aug-19 4:56
mveGerry Schmitz6-Aug-19 4:56 
QuestionListBox - Validate One or More Selections Pin
Kevin Marois22-Jul-19 9:30
professionalKevin Marois22-Jul-19 9:30 
I have this WPF ListBox:
<pre><ListBox Grid.Row="4"
            Grid.Column="1"
            ItemsSource="{Binding RuleActionsList}"
            SelectionMode="Multiple"
            Margin="5"
            Style="{StaticResource ListBoxStyle}">

<pre>
<i:Interaction.Behaviors>
    <cls:MultiSelectionBehavior SelectedItems="{Binding SelectedRuleActions}" />
</i:Interaction.Behaviors>

<ListBox.ItemTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding Converter={StaticResource enumDescConv}}"
                    Margin="2"/>
    </DataTemplate>
</ListBox.ItemTemplate>



The SelectedItems is bound to a behavior that update the ListBox's SelectedItems list. This part works fine.

The question is, how do I validate that there is at least one list item selected? Where do you set ValidatesOnNotifyDataErrors?

For other properties on the model, Iset ValidatesOnNotifyDataErrors=True and then do:
private void ValidateProperty(string propertyName)
{
    if (RuleGroup.Errors.TryGetValue(propertyName, out List<string> errors))
    {
        errors.Clear();
    }
    else
    {
        errors = new List<string>();
    }

    switch (propertyName)
    {
        case "GroupName":
            if (RuleGroup.GroupName == null)
            {
                errors.Add("The Group Name cannot be empty");
            }
            break;

    }

    RuleGroup.Errors[propertyName] = errors;
    if (errors.Count > 0)
    {
        RuleGroup.RaiseErrorsChanged(propertyName);
    }
}
and then
private void RuleGroup_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
    ValidateAll();
}
The property chaneg calls the validate, and for any property that is invalid I see the red box around the field in the ui.

But how do I do the same for the SelectedItems property?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 22-Jul-19 15:45pm.

QuestionWPF DataTemplateSelector Question Pin
Kevin Marois18-Jul-19 19:44
professionalKevin Marois18-Jul-19 19:44 
AnswerRe: WPF DataTemplateSelector Question Pin
Richard Deeming19-Jul-19 1:07
mveRichard Deeming19-Jul-19 1:07 
GeneralRe: WPF DataTemplateSelector Question Pin
Kevin Marois19-Jul-19 16:01
professionalKevin Marois19-Jul-19 16:01 
GeneralRe: WPF DataTemplateSelector Question Pin
Kevin Marois19-Jul-19 16:39
professionalKevin Marois19-Jul-19 16:39 
AnswerWPF ListBox Drag and drop Security elevation issue. Pin
Alisaunder12-Jun-19 16:13
memberAlisaunder12-Jun-19 16:13 
QuestionUser Control - Dependancy property MVVM Pin
MichaelLuna10-Jun-19 14:33
memberMichaelLuna10-Jun-19 14:33 
QuestionContentPresenter and ghost Views\ViewModels Pin
F4r145-Jun-19 0:29
memberF4r145-Jun-19 0:29 
AnswerRe: ContentPresenter and ghost Views\ViewModels Pin
Gerry Schmitz5-Jun-19 6:40
mveGerry Schmitz5-Jun-19 6:40 
GeneralRe: ContentPresenter and ghost Views\ViewModels Pin
F4r145-Jun-19 9:22
memberF4r145-Jun-19 9:22 
GeneralRe: ContentPresenter and ghost Views\ViewModels Pin
Gerry Schmitz6-Jun-19 5:47
mveGerry Schmitz6-Jun-19 5:47 
Questiondeployment size with WPF on .NET Core Pin
Super Lloyd2-Jun-19 14:47
memberSuper Lloyd2-Jun-19 14:47 
AnswerRe: deployment size with WPF on .NET Core Pin
Mycroft Holmes2-Jun-19 16:02
memberMycroft Holmes2-Jun-19 16:02 
GeneralRe: deployment size with WPF on .NET Core Pin
Super Lloyd2-Jun-19 16:44
memberSuper Lloyd2-Jun-19 16:44 

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.