發表文章

目前顯示的是 7月, 2010的文章

Tech.Days 2010

圖片
各位朋友們, Tech.Days 2010來了,有興趣的朋友記得快報名參加喔~

How to get rowindex / column of a grid control in silverlight?

圖片
這是在國外論壇上看到的一個問題,連結在 這邊 ,測試了一下之後,可以利用下面的方式來抓取;例如做了一個像是下圖的介面 項目的列表是放在Grid容器當中,XAML大致上像是這樣 在點選之後要去抓取被點選項目的相關Index,首先要去Handle Grid的滑鼠點選事件,例如 ContentGrid.MouseLeftButtonDown += new MouseButtonEventHandler(ContentGrid_MouseLeftButtonDown); 之後利用Grid.GetRow來達成,例如 void ContentGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //throw new NotImplementedException(); int rowindex = Grid.GetRow((FrameworkElement)e.OriginalSource); }