This commit is contained in:
YongAn 2021-07-24 23:20:07 +08:00
parent bb5ffdec2a
commit cd14c11622
2 changed files with 50 additions and 11 deletions

View File

@ -21,14 +21,16 @@
Width="400"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding WelcomeWord, UpdateSourceTrigger=PropertyChanged}"
Text="{Binding CurrentWorkRecord.WelcomeWord, UpdateSourceTrigger=PropertyChanged}"
TextChanged="{s:Action WelcomeWordTextChanged}"
/>
<Button
Margin="0,20,0,0"
Content="提交"
FontSize="24"
Command="{s:Action SubmitMe}"
IsEnabled="{Binding IsCanSubmitMe}"
CommandParameter="Hello"
IsEnabled="{Binding CurrentWorkRecord.IsCanSubmitMe}"
/>
</StackPanel>
</Grid>

View File

@ -1,8 +1,53 @@
using Stylet;
using System.Diagnostics;
using System;
using System.Security.Claims;
using Stylet;
namespace HelloStyletClient.Pages
{
public class ShellViewModel : Screen
{
// /// <summary>
// /// 欢迎词
// /// </summary>
// /// <value></value>
// public string WelcomeWord { get; set; } = "Hello Stylet!";
// /// <summary>
// /// 能否提交
// /// </summary>
// /// <value></value>
// public bool IsCanSubmitMe => !string.IsNullOrEmpty(CurrentWorkRecord.WelcomeWord);
/// <summary>
/// 当前工作记录
/// </summary>
/// <returns></returns>
public WorkRecord CurrentWorkRecord { get; set; } = new WorkRecord();
/// <summary>
/// 提交事件
/// </summary>
public void SubmitMe(string argument)
{
CurrentWorkRecord.WelcomeWord += $" {argument}";
}
/// <summary>
/// 欢迎词变更事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void WelcomeWordTextChanged(object sender, EventArgs e)
{
Debug.WriteLine(((System.Windows.Controls.TextBox)sender)?.Text ?? string.Empty);
}
}
/// <summary>
/// 工作记录
/// </summary>
public class WorkRecord : PropertyChangedBase
{
/// <summary>
/// 欢迎词
@ -15,13 +60,5 @@ namespace HelloStyletClient.Pages
/// </summary>
/// <value></value>
public bool IsCanSubmitMe => !string.IsNullOrEmpty(WelcomeWord);
/// <summary>
/// 提交事件
/// </summary>
public void SubmitMe()
{
WelcomeWord += " 提交";
}
}
}