AutoCompleteBox SelectedItem binding to textbox visibility

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

    Posted 26 Jan 2019 Link to this post


    How can i bind visibility property of a textbox to  a selecteditem of AutocompleteBox (with NullToVisibilityConverter) in Wpf? This code dont work.



     <telerik:RadButton Grid.Column="1"
                                                       Visibility="{Binding Path=SelectedItem, ElementName=RadAutoCompleteBox1, Converter={StaticResource NullToVisibilityConverter}}"
                                                       Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.Add}"
                                                       CommandParameter="{Binding Path=.}">
                                        <Image Source="{framework:ApplicationImage ImageX}" Height="16" Width="16"/>




                            <DataTemplate >
                                <telerik:RadAutoCompleteBox DisplayMemberPath="Name"
                                                            SearchText="{Binding Path=Name, Mode=TwoWay}"
                                                            BoxesItemStyle="{StaticResource RadAutoCompleteBoxStyle}"
                                                            NoResultsContent="{x:Static resources:Translations.lbl_NoMatches}"
    ItemsSource="{Binding Path=DataContext.Project.Names,
    RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}">

                                        <i:EventTrigger EventName="LostFocus">
    Command="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                    CommandParameter="{Binding Path=.}"/>


  2. Dinko
    Dinko avatar
    1106 posts

    Posted 30 Jan 2019 Link to this post

    Hello Ali,

    Thank you for the provided code snippet.

    If I have correctly understood your approach you want to bind a button outside of the RadGridView to the RadAutoCompleteBox in the cell. The tricky part here is that the RadAutoCompleteBox is visible when the cell is in edit mode. What you could try is to subscribe to the BeginningEdit and CellEditEnded. In the BeginningEdit event handler, you can bind the currently loaded RadAutoCompleteBox SelectedItem property to the Visibility of the RadButton.  And in the CellEditEnded hide the button when the cell edit mode ended. Check the attached project which demonstrates this. When you run the project click on the second column cell to go to edit mode. Then type London and remove it. Observed that the button at the bottom right corner appears and disappear. Hope this solution will work in your main application.

    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