尝试动画时,C#中的完成处理程序是什么样的?

tes*_*ing 6 c# xamarin.ios uiviewanimation ios xamarin

我想翻译这段代码

[UIView animateWithDuration:0.25
    animations:^{
        self.datePicker.alpha = 0.0f;
    }
    completion:^(BOOL finished){
        self.datePicker.hidden = YES;
    }
];
Run Code Online (Sandbox Code Playgroud)

到Xamarin iOS:

UIView.Animate (0.25,
    animation: () => {
        this.datePicker.Alpha = 0.0f;
    },
    completion: (finished){
        this.datePicker.Hidden = true;
    }
);
Run Code Online (Sandbox Code Playgroud)

问题出在completion块中.我如何在finished这里使用bool ?

我明白了

意外的符号 {

All*_*eng 8

这是基本的lambda表达式.

UIView.Animate (0.25,
    animation: () => {
        this.datePicker.Alpha = 0.0f;
    },
    completion: () => {
        this.datePicker.Hidden = true;
    }
);
Run Code Online (Sandbox Code Playgroud)

或者因为你的身体只有一个声明,你可以进一步减少它

UIView.Animate (0.25,
    animation: () => this.datePicker.Alpha = 0.0f,
    completion: () => this.datePicker.Hidden = true
);
Run Code Online (Sandbox Code Playgroud)