在carousel页面(比如6个内容页)中,我单击一个按钮,部分操作会更改该按钮上的文本,但其他所有内容页也必须更改。
我目前在carousel pages OnCurrentPageChanged()中遇到了这种情况,在这里我调用一个函数并传入“this”。
helpers.ChangeAll(this);
public void ChangeAll(CarouselSwipePage page)
{
foreach (SwipePageContent v in page.Children)
{
Button b = v.Content.FindByName<Button>("pause");
if (GlobalSettings.Settings.Default.CarouselCountEnabled) //this is set elsewhere and is used to determine whether the carousel is changing automatically, if it is then set the text to pause
{
b.Text = FontAwesomeFont.PauseCircleO;
}
else
{
b.Text = FontAwesomeFont.PlayCircleO;
}
}
}
这在android上正常,但在ios上,当用户单击按钮后滑动到下一个内容页时,按钮文本暂时是旧值,然后更改为新值,这是因为函数被调用OnCurrentPageChanged()。
除此之外,我相信一定有更好的方法来做这件事,它看起来垃圾。