Skip to content

Commit

Permalink
Remove White background of list (microsoft#2218)
Browse files Browse the repository at this point in the history
* Remove white background of list

* Removed comments

* Changed to ContainerContentChanging event

* add const variables instead of numbers

* Added comment before the updatelistSize function
  • Loading branch information
alekhyareddy28 authored and dsrivastavv committed Apr 21, 2020
1 parent 94042dd commit 267bb88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public partial class MainWindow
private Settings _settings;
private MainViewModel _viewModel;

const int ROW_COUNT = 4;
const int ROW_HEIGHT = 75;
const int MAX_LIST_HEIGHT = 300;

#endregion

public MainWindow(Settings settings, MainViewModel mainVM)
Expand Down Expand Up @@ -225,8 +229,10 @@ private void WindowsXamlHostListView_ChildChanged(object sender, EventArgs ev)
_resultList.DataContext = _viewModel;
_resultList.Tapped += SuggestionsList_Tapped;
_resultList.SuggestionsList.SelectionChanged += SuggestionsList_SelectionChanged;
_resultList.SuggestionsList.ContainerContentChanging += SuggestionList_UpdateListSize;
}


private bool IsKeyDown(VirtualKey key)
{
var keyState = CoreWindow.GetForCurrentThread().GetKeyState(key);
Expand Down Expand Up @@ -283,6 +289,17 @@ private void SuggestionsList_Tapped(object sender, TappedRoutedEventArgs e)
}
}

/* Note: This function has been added because a white-background was observed when the list resized,
* when the number of elements were lesser than the maximum capacity of the list (ie. 4).
* Binding Height/MaxHeight Properties did not solve this issue.
*/
private void SuggestionList_UpdateListSize(object sender, ContainerContentChangingEventArgs e)
{
int count = _viewModel?.Results?.Results.Count ?? 0;
int maxHeight = count < ROW_COUNT ? count * ROW_HEIGHT : MAX_LIST_HEIGHT;
_resultList.Height = maxHeight;
}

private void SuggestionsList_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
{
Windows.UI.Xaml.Controls.ListView listview = (Windows.UI.Xaml.Controls.ListView)sender;
Expand Down
1 change: 0 additions & 1 deletion src/modules/launcher/PowerLauncher/ResultListBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
xmlns:converter="clr-namespace:Wox.Converters;assembly=Wox"
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"
d:DataContext="{d:DesignInstance vm:ResultsViewModel}"
MaxHeight="{Binding MaxHeight}"
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}"
Expand Down

0 comments on commit 267bb88

Please sign in to comment.