1
沒有人知道如何做到這一點?如何以編程方式綁定DataGrid.SelectedCells
我知道如何在代碼
DataGrid DGrid = new DataGrid();
DGrid.SetBinding(... , myBinding);
結合
但不SelectedCells
因爲非DataGrid.SelectedCellsProperty
我發現只有DataGrid.SelectedIndexProperty
和DataGrid.SelectedItemProperty
任何可能的幫助感激!
哦,我不會寫一個行爲,因爲我看起來像一個混亂的事情,所以如果我明白你的權利,將不得不創建一個'DependencyObject'也不是我所期望的。有沒有其他方法可以做到這一點? – WiiMaxx 2013-02-28 09:00:08
如果您試圖從Window或UserControl中訪問DataGrid控件,則可以在其中聲明DependencyProperty(因爲所有這些都是從DependencyObject派生的)。 – Woodman 2013-02-28 10:12:56
我在我的'ViewModel'中構建了我的'DataGrid',並將它作爲'View'的'Property'提供,現在我將從'ViewModel'與另一個'Property'綁定到'SelectedCells'這就是我想要的: )。當然,我可以「綁定」到「selectedCellsChangedEvent」,但我不喜歡它 – WiiMaxx 2013-02-28 10:56:00