如何更改按钮的位置?
How to change the location of buttons?
如何更改 window 按钮的位置?
将它们设置在右上角,而不是居中。
我想在其余部分旁边安排与 window 交互的按钮,以将其他内容放在那里。
现在是:
<Controls:MetroWindow x:Class="JRGrace.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:JRGrace"
Title="MainWindow"
Height="350" Width="525"
TitlebarHeight="100">
<Controls:MetroWindow.TitleTemplate>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Bottom"
Margin="8 -1 8 0"
FontWeight="Light"
FontSize="{DynamicResource WindowTitleFontSize}"
FontFamily="{DynamicResource HeaderFontFamily}" />
</DataTemplate>
</Controls:MetroWindow.TitleTemplate>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands VerticalAlignment="Top">
<Button Content="settings" />
<Button>
<StackPanel Orientation="Horizontal">
<Rectangle Width="20"
Height="20"
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_cupcake}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="4 0 0 0"
VerticalAlignment="Center"
Text="deploy cupcakes" />
</StackPanel>
</Button>
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Grid>
</Grid>
使用 MahApps。
min/max 和关闭按钮也可以像其他演示者一样垂直对齐。
<Controls:MetroWindow.WindowButtonCommands>
<Controls:WindowButtonCommands VerticalAlignment="Top" Height="30" Style="{DynamicResource MahApps.Metro.Styles.WindowButtonCommands.Win10}" />
</Controls:MetroWindow.WindowButtonCommands>
<Controls:MetroWindow.LeftWindowCommands>
<Controls:WindowCommands VerticalAlignment="Bottom" Height="30">
</Controls:WindowCommands>
</Controls:MetroWindow.LeftWindowCommands>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands VerticalAlignment="Top" Height="30">
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Controls:MetroWindow.TitleTemplate>
<DataTemplate>
<Grid Height="30"
VerticalAlignment="Bottom">
<TextBlock Margin="8 -1 0 0"
VerticalAlignment="Center"
FontFamily="{DynamicResource HeaderFontFamily}"
FontSize="{DynamicResource WindowTitleFontSize}"
Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis" />
</Grid>
</DataTemplate>
</Controls:MetroWindow.TitleTemplate>
我为每个演示者添加了 30 像素的高度,因为这些演示者会自动计算其内部内容。
希望对您有所帮助!
如何更改 window 按钮的位置? 将它们设置在右上角,而不是居中。 我想在其余部分旁边安排与 window 交互的按钮,以将其他内容放在那里。
现在是:
<Controls:MetroWindow x:Class="JRGrace.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:JRGrace"
Title="MainWindow"
Height="350" Width="525"
TitlebarHeight="100">
<Controls:MetroWindow.TitleTemplate>
<DataTemplate>
<TextBlock Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Bottom"
Margin="8 -1 8 0"
FontWeight="Light"
FontSize="{DynamicResource WindowTitleFontSize}"
FontFamily="{DynamicResource HeaderFontFamily}" />
</DataTemplate>
</Controls:MetroWindow.TitleTemplate>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands VerticalAlignment="Top">
<Button Content="settings" />
<Button>
<StackPanel Orientation="Horizontal">
<Rectangle Width="20"
Height="20"
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_cupcake}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="4 0 0 0"
VerticalAlignment="Center"
Text="deploy cupcakes" />
</StackPanel>
</Button>
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Grid>
</Grid>
使用 MahApps。
min/max 和关闭按钮也可以像其他演示者一样垂直对齐。
<Controls:MetroWindow.WindowButtonCommands>
<Controls:WindowButtonCommands VerticalAlignment="Top" Height="30" Style="{DynamicResource MahApps.Metro.Styles.WindowButtonCommands.Win10}" />
</Controls:MetroWindow.WindowButtonCommands>
<Controls:MetroWindow.LeftWindowCommands>
<Controls:WindowCommands VerticalAlignment="Bottom" Height="30">
</Controls:WindowCommands>
</Controls:MetroWindow.LeftWindowCommands>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands VerticalAlignment="Top" Height="30">
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Controls:MetroWindow.TitleTemplate>
<DataTemplate>
<Grid Height="30"
VerticalAlignment="Bottom">
<TextBlock Margin="8 -1 0 0"
VerticalAlignment="Center"
FontFamily="{DynamicResource HeaderFontFamily}"
FontSize="{DynamicResource WindowTitleFontSize}"
Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis" />
</Grid>
</DataTemplate>
</Controls:MetroWindow.TitleTemplate>
我为每个演示者添加了 30 像素的高度,因为这些演示者会自动计算其内部内容。
希望对您有所帮助!