-
Notifications
You must be signed in to change notification settings - Fork 283
Open
Labels
bugSomething isn't workingSomething isn't working
Description
private static void Item_Loaded(object sender, RoutedEventArgs e)
{
var item = sender as ListBoxItem;
if (item != null)
{
var binding = new Binding("Opacity");
binding.Source = item;
binding.Mode = BindingMode.OneWay;
var dpd = DependencyPropertyDescriptor.FromProperty(UIElement.OpacityProperty, typeof(UIElement));
dpd.AddValueChanged(item, (s, args) =>
{
if (item.Opacity < 0.1)
{
var parent = ItemsControl.ItemsControlFromItemContainer(item);
if (parent != null)
{
var selectedItem = parent.ItemContainerGenerator.ItemFromContainer(item);
parent.Items.Remove(selectedItem);
parent.Items.Refresh();
}
}
});
}
}
dpd.AddValueChanged方法只添加对应handler,导致item被静态的gcroot持有无法释放,应该要在调用removevaluechanged
yanjinhuagood
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working