Multiple controls in CellEditTemplate

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    12 posts
    Member since:
    Sep 2012

    Posted 28 Jan 2013 Link to this post

    Hello,

    I currently have a ToggleButton and a Textblock inside a gridcell. The ToggleButton shows/hides a RowDetailsTemplate. How can I make the ToggleButton AND Textblock both visible within a CellEditTemplate.

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Account}"
        <telerik:GridViewDataColumn.CellTemplate>
            <DataTemplate>
                <Grid
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <ToggleButton IsChecked="{Binding DetailsVisible}" />
                    <TextBlock  Grid.Column="1" Text="{Binding Description}"/>
                </Grid>
            </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
        <telerik:GridViewDataColumn.CellEditTemplate>
            <DataTemplate>
                <TextBox Text="{Binding Description}" />
            </DataTemplate>
        </telerik:GridViewDataColumn.CellEditTemplate>
    </telerik:GridViewDataColumn>


    It seems to through an unhandled exception when I wrap both of these controls inside of a Grid within the CellEditTemplate. any ideas?
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 06 Feb 2013 Link to this post

    Hello,

    Here is a piece of working XAML:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}" >
                       <telerik:GridViewDataColumn.CellEditTemplate>
                           <DataTemplate>
                               <StackPanel>
                                   <TextBox Text="{Binding ID}"/>
                                   <Button Width="100" Height="20" Content="Button" />
                               </StackPanel>
                           </DataTemplate>
                       </telerik:GridViewDataColumn.CellEditTemplate>

    Additionally  I am attaching a runnable project demonstrating this in action.

    Kind regards,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top