我写下面的代码:
public void name(object sender, RoutedEventArgs e)
{
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 1.0;
myDoubleAnimation.To = 0.0;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.2));
sb1 = new Storyboard();
sb1.Children.Add(myDoubleAnimation);
Storyboard.SetTargetName(myDoubleAnimation, one.Name);
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Grid.OpacityProperty));
sb1.Begin(this);
if (one.Opacity == 0)
{
Container_one.Children.Remove(one);
}
}
Run Code Online (Sandbox Code Playgroud)
但它没有正确的做法.动画工作正常,但删除错误.如何将Storyboard-End与对方法的调用结合起来?
很多东西.
我更换ContentPresenter的DataGridCell的Template用TextBlock的,现在我搜索正确Binding的内容.
正常的方法是Text="{TemplateBinding Content}在TextBlock-这是行不通的.也Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Content, Mode=TwoWay}"行不通.
还有其他想法吗?