优化 UI 及删除冗余代码

在 `Thickness.xaml` 中,删除多余破折号并调整 `SettingsPageHyperlinkButtonMargin` 的值。
在 `ModulePage.xaml` 中,为 `RwmodItem` 的 `Grid` 添加 `ContextFlyout`,调整高度并删除 `themes:ButtonIcon` 按钮。
删除 `CommandBarFlyout` 及其包含的所有 `AppBarButton` 元素。
在 `ModulePage.xaml.cs` 中,删除 `Button_Click` 方法及其相关逻辑。
This commit is contained in:
muqing 2025-01-16 19:42:31 +08:00
parent f21ffd521a
commit bf8190e864
3 changed files with 14 additions and 48 deletions

View File

@ -1,6 +1,4 @@
<ResourceDictionary <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thickness x:Key="LargeTopMargin">0,36,0,0</Thickness> <Thickness x:Key="LargeTopMargin">0,36,0,0</Thickness>
<Thickness x:Key="LargeTopBottomMargin">0,36,0,36</Thickness> <Thickness x:Key="LargeTopBottomMargin">0,36,0,36</Thickness>
@ -31,6 +29,6 @@
<Thickness x:Key="MenuBarContentMargin">36,24,36,0</Thickness> <Thickness x:Key="MenuBarContentMargin">36,24,36,0</Thickness>
<Thickness x:Key="SettingsPageHyperlinkButtonMargin">-12,4,0,0</Thickness> <Thickness x:Key="SettingsPageHyperlinkButtonMargin">0,4,0,0</Thickness>
</ResourceDictionary> </ResourceDictionary>

View File

@ -14,9 +14,18 @@
<!-- 模组 --> <!-- 模组 -->
<DataTemplate x:Key="RwmodItem"> <DataTemplate x:Key="RwmodItem">
<Grid Background="{ThemeResource SystemColorWindowColor}" CornerRadius="9"> <Grid Background="{ThemeResource SystemColorWindowColor}" CornerRadius="9">
<Grid.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="解压" />
<MenuFlyoutItem Text="删除" />
<MenuFlyoutItem Text="重命名" />
<MenuFlyoutItem Click="Button_OpenDir" Text="资源管理器" />
</MenuFlyout>
</Grid.ContextFlyout>
<Grid <Grid
Width="130" Width="130"
Height="160" Height="150"
Padding="9,0,9,9"> Padding="9,0,9,9">
<Image <Image
Width="50" Width="50"
@ -24,11 +33,6 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Source="/Assets/image/rwmod.svg" /> Source="/Assets/image/rwmod.svg" />
<themes:ButtonIcon
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="Button_Click"
Glyph="&#xE712;" />
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom">
<TextBlock <TextBlock
HorizontalAlignment="Center" HorizontalAlignment="Center"
@ -65,7 +69,7 @@
</Grid.ContextFlyout> </Grid.ContextFlyout>
<Grid <Grid
Width="130" Width="130"
Height="160" Height="150"
Padding="9"> Padding="9">
<Image <Image
Width="50" Width="50"
@ -90,20 +94,6 @@
</DataTemplate> </DataTemplate>
<CommandBarFlyout x:Name="CommandBarFlyout1" Placement="Right">
<AppBarButton
Icon="Share"
Label="分享"
ToolTipService.ToolTip="分享" />
<AppBarButton
Click="Button_Delete"
Icon="Delete"
Label="删除"
ToolTipService.ToolTip="删除" />
<CommandBarFlyout.SecondaryCommands>
<AppBarButton Label="重命名" />
</CommandBarFlyout.SecondaryCommands>
</CommandBarFlyout>
</Page.Resources> </Page.Resources>
<Grid Margin="16"> <Grid Margin="16">

View File

@ -87,28 +87,6 @@ public sealed partial class ModulePage : Page
} }
/// <summary>
/// 打开模组
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
if (button != null)
{
var container = VisualTreeHelper.GetParent(button) as FrameworkElement;
if (container != null && container.DataContext is DataObject dataItem)
{
FlyoutShowOptions myOption = new FlyoutShowOptions();
myOption.ShowMode = FlyoutShowMode.Standard;
CommandBarFlyout1.ShowAt(button, myOption);
}
}
}
/// <summary> /// <summary>
/// 删除模组和文件夹 /// 删除模组和文件夹
/// </summary> /// </summary>