0
所以我爲我的xaml用戶控件創建了一個布爾依賴項屬性。但是,當xaml中的值設置爲false時,它在xaml中設置爲true時不觸發事件。無論如何,我怎樣才能把它發射出去?DependencyProperties與Bools:False導致事件不會觸發
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"));
}
}