我有这个XAML
<TableSection Title="Application">
<TextCell x:Name="appUpdated" Text="Updated" />
<TextCell x:Name="appVersion" Text="Application Version" />
</TableSection>
这个C#:
public InfoPage()
{
InitializeComponent();
appUpdated.Text = AS.appUpdated;
appVersion.Text = AS.appVersion;
}
有没有办法让我可以在文本的右边显示一个小问号并点击它打开一个带有解释的对话框?
请注意我正在寻找带有自定义渲染器的iOS解决方案。我之前找到了一些关于此的参考文献,但不能再找到例子了。
答案 0 :(得分:1)
请参阅此sample
还需要 ViewCellRenderer 并稍加改动。
将 NativeiOSCell 中的 CellImageView 从 UIImageView 替换为 UIButton ,因为我们需要点击事件到打开一个对话框并显示信息。
添加按钮点击事件以显示其他信息
CellImageView = new UIButton();
CellImageView.TouchUpInside += delegate
{
UIAlertView alert = new UIAlertView()
{
Title = HeadingLabel.Text,
Message = SubheadingLabel.Text
};
alert.AddButton("OK");
alert.Show();
};
修改按钮获取图像的方式
CellImageView.SetBackgroundImage(GetImage(cell.ImageFilename),UIControlState.Normal);
调整文字和图片的框架。
public override void LayoutSubviews()
{
base.LayoutSubviews();
HeadingLabel.Frame = new CGRect(5, 4, ContentView.Bounds.Width - 63, 25);
CellImageView.Frame = new CGRect(ContentView.Bounds.Width - 63, 5, 33, 33);
}