所以我为我的 xaml 用户控件创建了一个 bool 依赖属性。但是,当该值在 xaml 中设置为 false 时,它不会在 xaml 中设置为 true 时触发事件。无论如何,我怎样才能让它触发事件?
public static readonly DependencyProperty AvailableProperty =
DependencyProperty.Register("Available", typeof(bool), typeof(DetailPannel),
new PropertyMetadata(null, onAvailablePropertyChanged));
public bool Available
{
get { return (bool)GetValue(AvailableProperty); }
set { SetValue(AvailableProperty, value); }
}
private async static void onAvailablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var obj = d as DetailPannel;
bool avaible = (bool.Parse(e.NewValue.ToString()));
if(avaible == false )
{
obj.PreviewImage.Source = await ConvertToGreyscale(obj.PreviewImage);
obj.StateRelatedImage.Source = new BitmapImage(new Uri("ms-appx:///icon.png"));
}
}