Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove White background of list #2218

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we comment why, we have to hack around the Panel resizing itself? I'm not sure I fully understand and it would be good context for someone reading this. Particularly if its a known issue with xaml islands that may be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I shall add why we had to choose this path. TBH I'm not sure of the exact reason as to why it wasn't working. Binding Height/MaxHeight Properties does not work either.

{
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