Skip to content

Commit

Permalink
add: 标题栏绑定
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuuu committed Apr 26, 2024
1 parent 2193e91 commit 3a0e9e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 15 additions & 2 deletions llcomNext/LLCOM/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
namespace LLCOM.ViewModels
using CommunityToolkit.Mvvm.ComponentModel;
using System.Threading.Tasks;

namespace LLCOM.ViewModels
{

public partial class MainWindowViewModel : ViewModelBase
{
public string Greeting => "Welcome to Avalonia!";
/// <summary>
/// 标题栏
/// </summary>
[ObservableProperty]
public string _title = "LLCOM - Next";

public MainWindowViewModel()
{

}
}
}
10 changes: 1 addition & 9 deletions llcomNext/LLCOM/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:LLCOM.ViewModels"
Title="LLCOM - Next"
Title="{Binding Title}"
d:DesignHeight="450"
d:DesignWidth="800"
x:DataType="vm:MainWindowViewModel"
Expand All @@ -14,16 +14,8 @@
mc:Ignorable="d">

<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
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Greeting}" />

</Window>

0 comments on commit 3a0e9e1

Please sign in to comment.