自定义窗体标题栏及尺寸调整手柄完成
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:MVVMExample.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@@ -6,15 +6,39 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="MVVMExample.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
SystemDecorations="None"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="MVVMExample">
|
||||
|
||||
Title="MVVMExample"
|
||||
CanResize="True">
|
||||
<Window.Styles>
|
||||
<Style Selector="Window">
|
||||
<Setter Property="Background" Value="#0F000000"/>
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
<Design.DataContext>
|
||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
|
||||
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/> <!-- 标题栏行 -->
|
||||
<RowDefinition Height="*"/> <!-- 内容行 -->
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- 自定义标题栏 -->
|
||||
<Border Grid.Row="0" Height="40" Background="#007ACC" PointerPressed="TitleBar_PointerPressed"> <!-- 绑定拖拽事件 -->
|
||||
<Grid Margin="10,0">
|
||||
<TextBlock VerticalAlignment="Center" Foreground="White" Text="{Binding Path=Title, RelativeSource={RelativeSource AncestorType=Window}}"/>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Spacing="8">
|
||||
<Button x:Name="MinimizeBtn" Content="─" Width="40" Click="MinimizeBtn_Click"/>
|
||||
<Button x:Name="MaximizeBtn" Content="□" Width="40" Click="MaximizeBtn_Click"/>
|
||||
<Button x:Name="CloseBtn" Content="✕" Width="40" Background="Red" Click="CloseBtn_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!-- 主内容区 -->
|
||||
<Border Grid.Row="1" Background="White">
|
||||
<TextBlock Text="你的应用内容在这里" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<Border Grid.Row="2" Width="40" Height="40" Background="Red" HorizontalAlignment="Right" PointerPressed="Bar_PointerPressed"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user