我不确定这是否适合您的场景,但一种方法是忽略基于项目的点击事件:
void ClickOnItem(object sender, ItemClickEventArgs e)
{
var item = (SampleDataItem)e.ClickedItem;
// ignore one specific item - here we use UniqueId, but it could be
// any attribute...
if (string.Compare(item.UniqueId, "Group-1-Item-1") == 0)
return;
// normal processing here...
...
}
更新- 要以编程方式添加点击事件,您必须命名您的网格(x:Name
线):
<GridView Grid.Column="0" Grid.Row="1"
x:Name="myGridView"
SelectionMode="None"
IsItemClickEnabled="True"
ItemClick="ClickOnItem">
</GridView>
然后在后面的代码中,在页面的构造函数中添加handler:
public PageConstructor()
{
this.InitializeComponent();
myGridView.ItemClick += ClickOnItem;
}