RadAutoCompleBox in GridViewDataColumn

3 posts, 1 answers
  1. ali
    ali avatar
    5 posts
    Member since:
    Jan 2019

    Posted 04 Jan Link to this post

    I have a GridViewDataColumn, in the first column is an AutoCompleteBox for searching names in a ObservablceCollection.

    I have build the RadGridView with AutoCompleteBox like this:

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="*" IsReadOnly="False">
         <telerik:GridViewDataColumn.CellTemplate>
          <DataTemplate DataType="{x:Type detailViews:MyViewModel}">
           <Grid>
            <Grid.ColumnDefinitions>
             <ColumnDefinition Width="*"/>
             <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <telerik:RadAutoCompleteBox DisplayMemberPath="Name"
                                        TextSearchMode="Contains"
                   WatermarkContent="Suche..."
                   AutoCompleteMode="Suggest"
                   SelectionMode="Single"
                                        ItemsSource="{Binding Project.Names, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"  />
            <telerik:RadButton Grid.Column="1" HorizontalAlignment="Right" Style="{StaticResource RadImageButton}" ToolTip="Search"
                    Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.SearchFromDatabaseCommand}"
                    CommandParameter="{Binding Path=.}">
             <Image Grid.Column="1" Source="{framework:ApplicationImage image}" Width="16" Height="16" />
            </telerik:RadButton>
           </Grid>
          </DataTemplate>
         </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>

     

    My Problem is that the items of ObservableCollection not binded in autocompletebox. Is it possible with my type of implemetation of the AutoCompleteBox in the GridViewDataColumn?

  2. ali
    ali avatar
    5 posts
    Member since:
    Jan 2019

    Posted 04 Jan in reply to ali Link to this post

    The next question: How can i bind selecteditem with Name (DataMemberBinding={Binding Name}) in wpf ?
  3. Answer
    Dinko
    Admin
    Dinko avatar
    956 posts

    Posted 08 Jan Link to this post

    Hello Ali,

    Thank you for the provided code snippet. 

    What I would suggest you is to place the RadAutoCompleteBox in the CellEditTemplate and bind the SelectedItem property of the RadAutoCompleteBox. I have created a sample project which demonstrates how you can sync the selected item and bind the ItemsSource of the RadAutoCompleteBox control inside the cell. 

    Hope this project will be helpful.

    Regards,
    Dinko
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top