Settings
This commit is contained in:
@@ -3,27 +3,31 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace Hyperbar.UI.Windows;
|
namespace Hyperbar.UI.Windows;
|
||||||
|
|
||||||
public class ViewModelContentBinder(NavigationTargetCollection contents) :
|
public class ViewModelContentBinder(NavigationTargetCollection contents) :
|
||||||
IViewModelContentBinder
|
IViewModelContentBinder
|
||||||
{
|
{
|
||||||
public void Bind(FrameworkElement view,
|
public void Bind(FrameworkElement view,
|
||||||
object context)
|
object context)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (context.GetType().GetCustomAttributes<NavigationTargetAttribute>()
|
if (context.GetType().GetCustomAttributes<NavigationTargetAttribute>()
|
||||||
is IEnumerable<NavigationTargetAttribute> attributes)
|
is IEnumerable<NavigationTargetAttribute> attributes)
|
||||||
{
|
{
|
||||||
foreach (NavigationTargetAttribute attribute in attributes)
|
foreach (NavigationTargetAttribute attribute in attributes)
|
||||||
{
|
{
|
||||||
if (view.FindName(attribute.Name) is FrameworkElement content)
|
if (!contents.ContainsKey(attribute.Name))
|
||||||
{
|
{
|
||||||
contents.Add(attribute.Name, content);
|
if (view.FindName(attribute.Name) is FrameworkElement content)
|
||||||
void HandleUnloaded(object sender, RoutedEventArgs args)
|
|
||||||
{
|
{
|
||||||
view.Unloaded -= HandleUnloaded;
|
contents.Add(attribute.Name, content);
|
||||||
contents.Remove(attribute.Name);
|
void HandleUnloaded(object sender, RoutedEventArgs args)
|
||||||
}
|
{
|
||||||
|
view.Unloaded -= HandleUnloaded;
|
||||||
|
contents.Remove(attribute.Name);
|
||||||
|
}
|
||||||
|
|
||||||
view.Unloaded += HandleUnloaded;
|
view.Unloaded += HandleUnloaded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -9,14 +9,11 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.WinUI" Version="7.1.2" />
|
<PackageReference Include="CommunityToolkit.WinUI.Triggers" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
|
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2" />
|
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240205001-preview1" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240205001-preview1" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26031-preview" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26031-preview" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.1.24080.9" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.1.24080.9" />
|
||||||
<PackageReference Include="CustomExtensions.WinUI" Version="0.1.10-beta" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Hyperbar.Controls.Windows\Hyperbar.Controls.Windows.csproj" />
|
<ProjectReference Include="..\Hyperbar.Controls.Windows\Hyperbar.Controls.Windows.csproj" />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||||
xmlns:triggers="using:CommunityToolkit.WinUI.UI.Triggers">
|
xmlns:triggers="using:CommunityToolkit.WinUI">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent" />
|
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent" />
|
||||||
<SolidColorBrush x:Key="ButtonBorderBrush" Color="Transparent" />
|
<SolidColorBrush x:Key="ButtonBorderBrush" Color="Transparent" />
|
||||||
|
|||||||
@@ -6,11 +6,28 @@
|
|||||||
<Window.SystemBackdrop>
|
<Window.SystemBackdrop>
|
||||||
<MicaBackdrop />
|
<MicaBackdrop />
|
||||||
</Window.SystemBackdrop>
|
</Window.SystemBackdrop>
|
||||||
<NavigationView
|
<Grid>
|
||||||
x:Name="Settings"
|
<Grid.RowDefinitions>
|
||||||
IsBackButtonVisible="Collapsed"
|
<RowDefinition Height="43" />
|
||||||
IsPaneToggleButtonVisible="False"
|
<RowDefinition Height="*" />
|
||||||
IsSettingsVisible="False"
|
</Grid.RowDefinitions>
|
||||||
MenuItemTemplateSelector="{Binding ViewModelTemplateSelector}"
|
<Border Grid.Row="0">
|
||||||
MenuItemsSource="{x:Bind ViewModel, Mode=OneWay}" />
|
<TextBlock
|
||||||
|
Margin="15,0,0,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="Settings" />
|
||||||
|
</Border>
|
||||||
|
<NavigationView
|
||||||
|
Grid.Row="1"
|
||||||
|
IsBackButtonVisible="Collapsed"
|
||||||
|
IsPaneToggleButtonVisible="False"
|
||||||
|
IsSettingsVisible="False"
|
||||||
|
MenuItemTemplateSelector="{Binding ViewModelTemplateSelector}"
|
||||||
|
MenuItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||||
|
<ContentControl
|
||||||
|
x:Name="Settings"
|
||||||
|
Margin="12"
|
||||||
|
HorizontalContentAlignment="Stretch" />
|
||||||
|
</NavigationView>
|
||||||
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Hyperbar.UI.Windows;
|
using Hyperbar.UI.Windows;
|
||||||
using Microsoft.UI;
|
using Microsoft.UI;
|
||||||
|
using Microsoft.UI.Windowing;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
|
|
||||||
namespace Hyperbar.Windows;
|
namespace Hyperbar.Windows;
|
||||||
|
|||||||
Reference in New Issue
Block a user