【发布时间】:2012-03-20 13:25:22
【问题描述】:
我在一个部分中有以下内容:
_favElement = new StyledStringElement (string.Empty);
_favElement.Alignment = UITextAlignment.Center;
if (_room.IsFavourite) {
_favElement.Image = UIImage.FromBundle ("Images/thumbs_up.png");
_favElement.Caption = "Unmark as Favourite";
} else {
_favElement.Image = null;
_favElement.Caption = "Mark as Favourite";
}
_favElement.Tapped += favElement_Tapped;
然后,当我按下元素时,我希望发生以下情况:
private void favElement_Tapped ()
{
if (_room.IsFavourite) {
_favElement.Image = null;
_favElement.Caption = "Mark as Favourite";
} else {
_favElement.Image = UIImage.FromBundle ("Images/thumbs_up.png");
_favElement.Caption = "Unmark as Favourite";
}
_room.IsFavourite = !_room.IsFavourite;
}
但是,当点击元素时,实际元素中的图像和文本不会改变。是否有刷新方法或必须调用的东西?我也尝试过更改 Tapped 上的附件,但没有任何变化。后面的属性确实反映了正确的值。
【问题讨论】:
标签: xamarin.ios monotouch.dialog