2014-04-25 21 views
0

我在平板電腦「Windows Phone 8」上的應用程序「外殼」上工作。 我只是試圖在命令執行時禁用我所有的用戶UI控制器。 所有控制器按鈕在「禁用」模式下都能正常工作,但我不知道爲什麼,我的控制器「TextBox」仍處於活動狀態。這是很煩人的,因爲用戶仍然可以通過點擊輸入字段杜蘭特的手術治療:「(爲什麼如果我禁用我的文本框爲false,總是等於true?

感謝很多人;-)

這是我的代碼,我嘗試禁用和啓用後,我的操作表面處理:

//.... 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的照片..但我的按鈕小號禁用:

enter image description here

+0

你能包括你的xaml嗎? – helb

+0

如何在頁面中的所有內容上都有一個透明網格,並在想要阻止用戶交互時顯示它?這很容易,你會寫更少的代碼。 – disklosr

+0

'ttbx_shell'!='ttbxInputShell'。這是一個複製和粘貼錯誤,或兩個不同的控制,你是與錯誤的交互? (因此你的問題...) –

回答

0

啓用/禁用未添加到您的UI控件。 UI中顯示的名稱爲「ttbx_shell」的原始控件因此不受影響。

+0

謝謝你這麼mutchhhh!現在完美的工作^^^^太好了 –

相關問題