C# 为什么如果我禁用我的文本框为false,它总是等于true?
我在WindowsPhone8平台上开发应用程序外壳。 我只是尝试在执行命令时禁用所有用户UI控制器。 所有控制器按钮在禁用模式下都能正常工作,但我不知道为什么,我的控制器文本框仍然处于活动状态。这非常烦人,因为用户仍然可以单击输入字段durant a operation treatment:' 谢谢大家;- 这是我的代码,我在操作完成后尝试禁用和启用:C# 为什么如果我禁用我的文本框为false,它总是等于true?,c#,windows-phone-8,user-controls,textbox,radtextbox,C#,Windows Phone 8,User Controls,Textbox,Radtextbox,我在WindowsPhone8平台上开发应用程序外壳。 我只是尝试在执行命令时禁用所有用户UI控制器。 所有控制器按钮在禁用模式下都能正常工作,但我不知道为什么,我的控制器文本框仍然处于活动状态。这非常烦人,因为用户仍然可以单击输入字段durant a operation treatment:' 谢谢大家;- 这是我的代码,我在操作完成后尝试禁用和启用: //.... Get the controller textBox in my class ttbxInputShell = new RadT
//.... Get the controller textBox in my class
ttbxInputShell = new RadTextBox() { Text = (ContentPanel.FindName("ttbx_shell") as RadTextBox).Text };
//....
// Disable Ui
#region DisableUI
public void DisableUi()
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
ttbxInputShell.IsEnabled = false; //No Work
ttbxInputShell.IsHitTestVisible = false; //No Work
ttbxInputShell.IsReadOnly = true; //No Work
btnLastCommande.IsEnabled = false; //Work
btnHelpCommande.IsEnabled = false; //Work
btnExecuteCommande.IsEnabled = false; //Work
});
}
#endregion
// Enable Ui
#region EnableUI
public void EnableUi()
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
ttbxInputShell.IsEnabled = true;
ttbxInputShell.IsHitTestVisible = true;
ttbxInputShell.IsReadOnly = false;
btnLastCommande.IsEnabled = true;
btnHelpCommande.IsEnabled = true;
btnExecuteCommande.IsEnabled = true;
});
}
#endregion
XAML代码
<TextBox x:Name="ttbx_shell" KeyDown="ttbx_shell_KeyDown_1" GotFocus="ttbx_shell_GotFocus_1" LostFocus="ttbx_shell_LostFocus_1" TextChanged="ttbx_shell_TextChanged_1" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextWrapping="Wrap" Height="100" Margin="-7,-8,0,0" FontSize="26" Padding="3,6,3,0" Grid.Row="2" FontFamily="dos_font.ttf#Perfect DOS VGA 437 Win" />
<Button x:Name="btnLastCommande" Content="F1" Grid.Row="2" Margin="231,0,55,0" Grid.ColumnSpan="3" Tap="btnLastCommande_Tap" />
<Button x:Name="btnHelpCommande" Content="?" Grid.Row="2" Grid.Column="1" Margin="55,0,95,0" Grid.ColumnSpan="3" Tap="btnHelpCommande_Tap"/>
<Button x:Name="btnExecuteCommande" Grid.Row="2" Grid.Column="2" Content="Enter" Padding="-3" Margin="55,0,-5,0" Grid.ColumnSpan="2" Tap="btnExecuteCommande_Tap"/>
</Grid>
这是我的应用程序的图片,在这里你可以找到输入仍然是enbale。。但按钮是禁用的:
启用/禁用未添加到UI的控件。因此,UI中显示的名为ttbx_shell的原始控件不受影响。是否可以包含xaml?如何在页面中的所有内容顶部设置一个透明网格,并在想要阻止用户交互时显示该网格?这样做更简单,而且编写的代码也更少。ttbx_shell!=ttbxInputShell。这是一个复制粘贴错误,还是两个不同的控件,而您使用的是错误的控件?因此你的问题…@helb好的,我刚刚完成添加Xaml代码,@disklosr当然,如果我没有选择,我可能会使用这个替代方案-非常感谢你!!现在很好用^^^^太好了