@@ -5041,7 +5041,10 @@ private void Autocomplete_ChoosingItemContainer(ListViewBase sender, ChoosingIte
50415041 {
50425042 if ( args . ItemContainer == null )
50435043 {
5044- args . ItemContainer = new TextGridViewItem ( ) ;
5044+ args . ItemContainer = new TextGridViewItem
5045+ {
5046+ HorizontalContentAlignment = HorizontalAlignment . Stretch
5047+ } ;
50455048 args . ItemContainer . Style = sender . ItemContainerStyle ;
50465049
50475050 _autocompleteZoomer . ElementPrepared ( args . ItemContainer ) ;
@@ -5061,10 +5064,41 @@ private void Autocomplete_ChoosingItemContainer(ListViewBase sender, ChoosingIte
50615064 args . ItemContainer . CornerRadius = new CornerRadius ( ) ;
50625065 }
50635066
5067+ args . ItemContainer . PointerEntered -= Autocomplete_PointerEntered ;
5068+ args . ItemContainer . PointerExited -= Autocomplete_PointerExited ;
5069+
5070+ if ( args . Item is string )
5071+ {
5072+ args . ItemContainer . PointerEntered += Autocomplete_PointerEntered ;
5073+ args . ItemContainer . PointerExited += Autocomplete_PointerExited ;
5074+ }
5075+
50645076 args . ItemContainer . ContentTemplate = sender . ItemTemplateSelector . SelectTemplate ( args . Item , args . ItemContainer ) ;
50655077 args . IsContainerPrepared = true ;
50665078 }
50675079
5080+ private void Autocomplete_PointerEntered ( object sender , PointerRoutedEventArgs e )
5081+ {
5082+ if ( sender is SelectorItem { ContentTemplateRoot : Grid content } )
5083+ {
5084+ if ( content . Children . Count > 1 && content . Children [ 1 ] is Button button )
5085+ {
5086+ button . Visibility = Visibility . Visible ;
5087+ }
5088+ }
5089+ }
5090+
5091+ private void Autocomplete_PointerExited ( object sender , PointerRoutedEventArgs e )
5092+ {
5093+ if ( sender is SelectorItem { ContentTemplateRoot : Grid content } )
5094+ {
5095+ if ( content . Children . Count > 1 && content . Children [ 1 ] is Button button )
5096+ {
5097+ button . Visibility = Visibility . Collapsed ;
5098+ }
5099+ }
5100+ }
5101+
50685102 private void Autocomplete_ContainerContentChanging ( ListViewBase sender , ContainerContentChangingEventArgs args )
50695103 {
50705104 if ( args . InRecycleQueue )
@@ -5137,6 +5171,12 @@ private void Autocomplete_ContainerContentChanging(ListViewBase sender, Containe
51375171
51385172 var title = content . Children [ 0 ] as TextBlock ;
51395173 title . Text = hashtag ;
5174+
5175+ var clear = content . Children [ 1 ] as Button ;
5176+ clear . Click -= RemoveHashtag_Click ;
5177+ clear . Click += RemoveHashtag_Click ;
5178+ clear . Tag = hashtag ;
5179+ clear . Visibility = Visibility . Collapsed ;
51405180 }
51415181 else if ( args . Item is Sticker sticker )
51425182 {
@@ -5155,6 +5195,21 @@ private void Autocomplete_ContainerContentChanging(ListViewBase sender, Containe
51555195 args . Handled = true ;
51565196 }
51575197
5198+ private async void RemoveHashtag_Click ( object sender , RoutedEventArgs e )
5199+ {
5200+ if ( sender is Button { Tag : string hashtag } )
5201+ {
5202+ _viewModel . ClientService . Send ( new RemoveRecentHashtag ( hashtag ) ) ;
5203+
5204+ await Task . Yield ( ) ;
5205+
5206+ if ( ListAutocomplete . ItemsSource is AutocompleteCollection collection )
5207+ {
5208+ collection . Remove ( hashtag ) ;
5209+ }
5210+ }
5211+ }
5212+
51585213 private bool ? _replyEnabled = null ;
51595214 private bool _actionCollapsed = true ;
51605215
0 commit comments