Issue with enabling dropdown on Focus.

1 posts, 0 answers
  1. Avani
    Avani avatar
    2 posts
    Member since:
    Apr 2013

    Posted 22 May 2013 Link to this post

    Hi,

    I do have radautocompletebox with the dropdown button.

    On clicking the button and on focus of the radautocomplete box, the dropdown is supposed to open.
    The issue is when I select an item from the dropdown opened by button click and select an item from it, the selected item automatically sets to the text box inside the radautocompletebox thereby focusing on the same and the onFocus method gets called which is opening dropdown again which is not required.
    This process happens so rapidly that two values (one from each dropdown) gets selected on a single click.
    Kindly let me know in case if I am going wrong somewhere.

    Below is the xaml code:
    <ScrollViewer VerticalAlignment="Top" HorizontalScrollBarVisibility="Disabled" Grid.Column="0" VerticalScrollBarVisibility="Auto" Height="40" Width="186"  >
                            <telerik:RadAutoCompleteBox WatermarkContent="{Binding Path=WatermarkContent}"  HorizontalAlignment="Left" Name="radDeseaseCategoryAutoCompleteBox" Width="186"
                                        SelectionMode="Multiple"
                                        FilteringBehavior="{StaticResource EmptyTextFilteringBehavior}"
                TextSearchMode="Contains"
                TextSearchPath="Name" MinHeight="35"
                                         AutoCompleteMode="Suggest"
                                         ItemsSource="{Binding Path=DiseaseCategoryCollection, Source={StaticResource reportDropdownInfo}}"
                                         SelectedItems="{Binding Path=SelectedDiseaseCategoryCollection, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
                                         GotFocus="DeseaseCompleteBoxGotFocus" LostFocus="DeseaseCompleteBoxLostFocus"
                                        >
                                <telerik:RadAutoCompleteBox.DropDownItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name}" Width="190"/>
                                    </DataTemplate>
                                </telerik:RadAutoCompleteBox.DropDownItemTemplate>
                                <telerik:RadAutoCompleteBox.BoxesItemTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{Binding Name}" IsEnabled="False" TextWrapping="Wrap" Width="140" MaxWidth="140"  Background="White" />
                                    </DataTemplate>
                                </telerik:RadAutoCompleteBox.BoxesItemTemplate>
                            </telerik:RadAutoCompleteBox>
                        </ScrollViewer>
                        <telerik:RadButton Grid.Column="1" IsTabStop="False"
                                   Click="DeseaseRadButtonClick"
                                   VerticalAlignment="Top" HorizontalAlignment="Right"
                                   Width="15"
                                   Height="40" Grid.Row="1">
                            <Path Data="M0,0 L4,0 L4,4 z" Fill="Black" HorizontalAlignment="Right" Height="5" Stretch="Fill" VerticalAlignment="Center" Width="5" UseLayoutRounding="False" RenderTransformOrigin="0.5,0.5">
                                <Path.RenderTransform>
                                    <RotateTransform Angle="135" />
                                </Path.RenderTransform>
                            </Path>
                        </telerik:RadButton>

    Here is the method in code behind. .

     private void MechOfActRadButtonClick(object sender, RoutedEventArgs e)
            {
                radMecofActionAutoCompleteBox.Focus();
            }

            private void RadMecofActionAutoCompleteBoxGotFocus(object sender, RoutedEventArgs e)
            {
                radMecofActionAutoCompleteBox.WatermarkContent = "";
                radMecofActionAutoCompleteBox.Populate(radMecofActionAutoCompleteBox.SearchText);
            }
Back to Top