Skip to content

Commit

Permalink
Remove back button taking up space in titlebar, move titlebar over
Browse files Browse the repository at this point in the history
  • Loading branch information
MolotovCherry committed Nov 13, 2023
1 parent 2ee1b5d commit ca861f4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
2 changes: 0 additions & 2 deletions Virtual Display Driver Control/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

namespace Virtual_Display_Driver_Control {
public partial class App : Application {
#nullable enable
public static Window? Window { get; private set; }
#nullable restore

public App() {
InitializeComponent();
Expand Down
2 changes: 1 addition & 1 deletion Virtual Display Driver Control/Helpers/ThemeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static void ColorChangedCb(UISettings sender, object args) {
var dispatcher = App.Window?.DispatcherQueue;

// run it on the main window thread
dispatcher.TryEnqueue(() => {
dispatcher?.TryEnqueue(() => {
ElementTheme theme;
if (ShouldSystemUseDarkMode()) {
theme = ElementTheme.Dark;
Expand Down
42 changes: 23 additions & 19 deletions Virtual Display Driver Control/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,48 @@
Title="Virtual Display Driver Control">

<Grid x:Name="RootGrid" Canvas.ZIndex="1" Background="{ThemeResource Background}">
<Grid.Resources>
<Thickness x:Key="NavigationViewContentMargin">0,48,0,0</Thickness>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Grid x:Name="AppTitleBar"
Canvas.ZIndex="1"
Height="{Binding ElementName=NavView, Path=CompactPaneLength}"
IsHitTestVisible="True"
VerticalAlignment="Top">
Height="{Binding ElementName=NavView, Path=CompactPaneLength}"
IsHitTestVisible="True"
VerticalAlignment="Top"
Grid.Row="0">

<Image Source="ms-appx:///Assets/icon.png"
HorizontalAlignment="Left"
Width="16" Height="16"
Margin="0,0"/>
HorizontalAlignment="Left"
Width="16" Height="16"
Margin="15,0,0,0"/>

<TextBlock x:Name="AppTitleTextBlock" Text="{StaticResource AppTitleName}"
TextWrapping="NoWrap"
Style="{StaticResource CaptionTextBlockStyle}"
VerticalAlignment="Center"
Margin="25,0,0,0"/>
TextWrapping="NoWrap"
Style="{StaticResource CaptionTextBlockStyle}"
VerticalAlignment="Center"
Margin="40,0,0,0"/>
</Grid>

<NavigationView
x:Name="NavView"
PaneDisplayMode="LeftCompact"
IsPaneToggleButtonVisible="False"
DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
Loaded="NavView_Loaded"
SelectionChanged="NavView_SelectionChanged">

SelectionChanged="NavView_SelectionChanged"
IsBackButtonVisible="Collapsed"
Grid.Row="1">

<NavigationView.MenuItems>
<NavigationViewItem Content="Monitors" Tag="MonitorsView">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE7F4;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
</NavigationView.MenuItems>

<Frame x:Name="ContentFrame"/>

</NavigationView>
</Grid>

Expand Down
9 changes: 0 additions & 9 deletions Virtual Display Driver Control/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ public MainWindow() {
}
}

private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args) {
AppTitleBar.Margin = new Thickness() {
Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
Top = AppTitleBar.Margin.Top,
Right = AppTitleBar.Margin.Right,
Bottom = AppTitleBar.Margin.Bottom
};
}

private void NavView_Loaded(object sender, RoutedEventArgs e) {
foreach (NavigationViewItemBase item in NavView.MenuItems) {
if (item is NavigationViewItem && item.Tag.ToString() == "MonitorsView") {
Expand Down
1 change: 1 addition & 0 deletions Virtual Display Driver Control/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</Style.Setters>
</Style>
</Page.Resources>

<Grid x:Name="RootGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down

0 comments on commit ca861f4

Please sign in to comment.