私はWPFをかなり新しくしていて、アプリケーションのボタンを一時的に無効にする簡単なソリューションを探しています。WPFアプリケーションでボタンを一時的に無効にするにはどうすればいいですか?
ボタンをクリックして:
private void Calculate_Click(object sender, RoutedEventArgs e)
{
this.AreButtonsEnabled = false;
System.Threading.Thread.Sleep(1000);
this.AreButtonsEnabled = true;
}
XAML:ここで私がやっているものです
<Button x:Name="OtherButton" IsEnabled="{Binding AreButtonsEnabled}" Content="OtherButton" HorizontalAlignment="Left" Margin="165,152,0,0" VerticalAlignment="Top" Width="75"/>
期待通りに結合作品を、私は有効にし、この1回の呼び出しでボタンを無効にすると、非アクティブ化は行われません。ボタンを適切に非アクティブにするためのGUIの取得方法を教えてください。
EDIT
(正常に動作します)通知イベント:
public partial class MainWindow : Window, INotifyPropertyChanged
{
private bool areButtonsEnabled;
public bool AreButtonsEnabled
{
get { return this.areButtonsEnabled; }
set { areButtonsEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs("AreButtonsEnabled")); }
}
注 私は、.NET 3.5にバインドされています。
あなたが "AreButtonsEnabled" プロパティが宣言されている方法を投稿してもらえますか? –
おそらく、UIがスリープする前に 'AreButtonsEnabled'の設定にfalseに反応する時間がないからでしょう。 – ChrisF
RelayCommand –