我在TextBox上显示计时器。当我按下它时,我调用了暂停计时器的方法,然后我需要能够使用键盘将数据写入到TextBox中(然后,我会将这些数字数据解析为hh / mm / ss格式)。但是使用块TextBox.InputBindings
时,我什么都不能写,它阻止了用户输入。我该怎么解决?
<Grid>
<TextBox Name="textTimeTop" HorizontalAlignment="Left" Height="35" Margin="20,20,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="120" FontSize="24"
Text="{Binding TestTimer.TimeFormat, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<MouseBinding Command="{Binding Path=TextBoxPress}" MouseAction="LeftClick"/>
</TextBox.InputBindings>
</TextBox>
</Grid>
ViewModel
public class UserInteractiton
{
public UserInteractiton()
{
TextBoxPress = new DelegateCommand(TextBoxGotFocus);
}
public ICommand TextBoxPress { get; private set; }
private void TextBoxGotFocus(object obj)
{
TestTimer.StopTimer();
}
}
答案 0 :(得分:1)
尝试删除命令绑定
match