Wpf DataTrigger绑定设置程序属性不工作

Wpf DataTrigger绑定设置程序属性不工作,wpf,xaml,binding,datatrigger,Wpf,Xaml,Binding,Datatrigger,需要根据数据库查询更改按钮可见性。我在下面试过了,但没有达到我的预期AlarmEnableStatus会按预期更改值,但UI不会更改 HomeView.xaml <Button x:Name="AlarmButton" Content="Warning!" Margin="12,0,6,0" BorderThickness="1" Width="100" Height="30" Style="{StaticResource AlarmButtonStyle}" Foregr

需要根据数据库查询更改按钮可见性。我在下面试过了,但没有达到我的预期<代码>AlarmEnableStatus会按预期更改值,但UI不会更改

HomeView.xaml

<Button x:Name="AlarmButton" Content="Warning!" 
  Margin="12,0,6,0" BorderThickness="1" Width="100" Height="30" 
  Style="{StaticResource AlarmButtonStyle}"
  Foreground="#717171" FontWeight="SemiBold" FontSize="17"/>

-------

<Style x:Key="AlarmButtonStyle" TargetType="Button" BasedOn="{StaticResource CornerRadiusButtonStyle}">
   <Setter Property="Visibility" Value="Visible"/>
   <Style.Triggers>
       <DataTrigger Binding="{Binding AlarmEnableStatus}" Value="False">
            <Setter Property="Visibility" Value="Hidden"/>
       </DataTrigger>
   </Style.Triggers>
</Style>

AlarmEnableStatus属性不会触发更改通知。考虑实现IntIfyPrimTyC改接口并从属性设置器中激发其属性更改的事件。谢谢@克莱门斯。不知道INotifyPropertyChanged的

public bool AlarmEnableStatus { get; private set; }

-------

DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(60);
timer.Tick += timer_Tick;
timer.Start();

-------

private void timer_Tick(object sender, EventArgs e)
{
  int isCount = HeaderDataSet.PendingFailedCount;
    if ((!AlarmEnableStatus) & (isCount > 0))
    {
       AlarmEnableStatus = true;      
    }
    else
   {
      AlarmEnableStatus = false;
  }
}