Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
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..

XML
<DataTemplate x:Key="ListDataTemplate">
        <Grid TextBlock.FontSize="15" HorizontalAlignment="Left">
            <Grid.ColumnDefinitions>
                <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"/>
            </Grid.ColumnDefinitions>
            <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}"/>
        </Grid>
    </DataTemplate>
Posted

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900