Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Pop up is not showing properly

$
0
0

Hi,

I want to show pop up , serves as suggestion for the textbox.

This is my code,

<Grid><Grid.RowDefinitions><RowDefinition /></Grid.RowDefinitions><TextBox x:Name="txtBox" VerticalAlignment="Top"
                 Text="{Binding TextSearch,UpdateSourceTrigger=PropertyChanged}"
                 TextChanged="txtBox_TextChanged"/><Popup x:Name="autoSuggest"  Width="250" Height="100"
               Placement="Bottom" PlacementTarget="{Binding ElementName=txtBox}" ><ListBox Width="250" Height="100" x:Name="suggestionWords" Background="AliceBlue" SelectionChanged="suggestionWords_SelectionChanged"
                     ItemsSource="{Binding TargetSuggestionWords}"/></Popup></Grid>

 private void txtBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (TextSearch.Length > 0)
            {TargetSuggestionWords = SuggestionWords.Where(x => x.StartsWith(TextSearch)).ToList();
                if (TargetSuggestionWords.Count > 0)
                {autoSuggest.StaysOpen = true;
                }
            }
        }

I am setting the "IsOpen" property of the PopUp in code behind. But still i am unable to get it.

I have commented out, the popup for checking. The list box is showing perfectly.

But enclosing the listbox in side the popup, is not working.

May i kindly know, where i am mistaking.

Thanks in advance.


NANDAKUMAR.T


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>