Help with binding the checkbox in DataboundListbox

3 posts, 1 answers
  1. GJ Kuz
    GJ Kuz avatar
    29 posts
    Member since:
    May 2011

    Posted 18 Jan 2012 Link to this post

    Dear Telerik Team,

    Is it possible to bind the checkbox in the DataboundListbox? I am using the following datatemplate as the ItemTemplate of the RadDataboundListbox.
    <phone:PhoneApplicationPage.Resources>
            <DataTemplate x:Key="ListBoxItemTemplate">
                <Grid HorizontalAlignment="Stretch" Width="420">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100" />
                        <ColumnDefinition Width="*" />                                  
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50*"/>
                        <RowDefinition Height="50*"/>
                    </Grid.RowDefinitions>
     
                    
                    <CheckBox
                        IsChecked="{Binding IsFavorite, Mode=TwoWay}"
                        Grid.Column="0" Grid.RowSpan="2" VerticalAlignment="Top"/>
     
                    <TextBlock
                        Text="{Binding Title}"
                        FontSize="{StaticResource PhoneFontSizeLarge}"
                        Grid.Column="1"                    
                        VerticalAlignment="Top"
                        Margin="-36, 12, 0, 0"/>
     
                    <TextBlock
                        Text="{Binding Description}"
                        FontSize="{StaticResource PhoneFontSizeMedium}"
                        Grid.Column="1"
                        Grid.Row="1"                    
                        VerticalAlignment="Top"
                        Margin="-36, 12, 0, 0"
                        TextWrapping="Wrap"/>
                </Grid>
            </DataTemplate>
        </phone:PhoneApplicationPage.Resources>

    This is my RadListbox. By default I want the checkboxes to be visible. Is there any way I could eliminate the Checkbox from my DataTemplate and bind the IsFavorite property to the built-in checkbox in RadDataBouldListbox? I would prefer to use the built-in checkbox since I am using the ItemCheckedStateChanging event.

     

    <telerikPrimitives:RadDataBoundListBox
                   x:Name="lstItems"
                   Margin="-10,0,-12,0"
                   CheckModeDeactivatedOnBackButton="False"
                   EmptyContent=""                
                   IsCheckModeEnabled="True"
                   IsCheckModeActive="True" 
                   ItemsSource="{Binding Items}" 
                   Grid.Row="1"
                   ItemTemplate="{StaticResource ListBoxItemTemplate}"
                   ItemCheckedStateChanging="lstItems_ItemCheckedStateChanging"/>

    Really appreciate some help on this.

    thanks,
    Gilles
  2. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 20 Jan 2012 Link to this post

    Hello Gilles,

    Thank you for your question.

    If you want to use the built-in checkbox, you can use the ItemCheckedPath property. In your case you should simply add
    ItemCheckedPath = "IsFavorite"

    I hope this helps. Have a great day!

    Greetings,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. GJ Kuz
    GJ Kuz avatar
    29 posts
    Member since:
    May 2011

    Posted 20 Jan 2012 Link to this post

    Thank you Todor. That worked like a charm.

    thanks,
    Gilles
Back to Top