Click here to Skip to main content
11,483,002 members (73,245 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: WPF DataTemplate MVVM
I am using a ListBox with a DataTemplate. in each row of listbox data items, it will have 2 checkbox (IS_Like_Apple, IS_Like_Orange). Any idea on how to write the validation on checkbox in each row of items? (Must be minimum 1 checkbox is selected). Anyone have an idea for it? btw,i'm using mvvm.
this is my datatemplate code..
<DataTemplate x:Key="ListDataTemplate">
        <Grid TextBlock.FontSize="15" HorizontalAlignment="Left">
                <ColumnDefinition Width="Auto" SharedSizeGroup="ID"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="Name"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="Email"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="Like_Apple"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="Like_Orange"/>
            <TextBlock Grid.Column="0"  Text="{Binding  Path=WWID}"  />
            <TextBlock Grid.Column="1"  Text="{Binding  Path=Name}"  />
            <TextBlock Grid.Column="2"  Text="{Binding  Path=Email}" />
            <CheckBox Grid.Column="3"  IsChecked="{Binding Path=IS_Like_Apple}"/>
            <CheckBox Grid.Column="4"  IsChecked="{Binding Path=IS_Like_Orange}"/>
Posted 23-Dec-12 14:54pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi, DataTemplate code is not enough!
Provide community with your MVVM model, and so on...

Fisrt thing that comes to my mind is:
- your model must to inherit IDataErrorInfo interface.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100