【发布时间】:2021-07-25 16:06:01
【问题描述】:
我有一个文本块,我想通过他的绑定属性将其从 false 变为 true。 该属性已更改为 true,但文本框的文本保持为 false。 我怎样才能做到这一点。 感谢您的帮助。
<TextBlock x:Name="resBlock" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" Height="50" Text="{Binding Source={StaticResource Locator}, Path=Main.Result}" TextAlignment="Center" FontSize="30" />
public class MainViewModel : ViewModelBase
{
public MainViewModel()
{
LoginCommand = new RelayCommand(Login);
user = new User();
}
DataService service = new DataService();
public User user { get; set; }
public bool Result { get; set; }
public ICommand LoginCommand { get; }
public async void Login()
{
Result = await service.LoginAsync(user); // get True
}
}
【问题讨论】: