如何選擇一個卡上的鼠標右鍵單擊Infragistics XamDataCards WPF控件? XamDataCards.ActiveDataItem屬性也應該改變。選擇一個卡在鼠標右鍵單擊Infragistics XamDataCards
1
A
回答
1
該解決方案也將啓動,如果卡的標題是正確的點擊卡:
class XamDataCardsActivateOnRightMouseClickBehavior : Behavior<XamDataCards>
{
protected override void OnAttached()
{
AssociatedObject.PreviewMouseRightButtonDown += AssociatedObjectPreviewMouseRightButtonDown;
}
private void AssociatedObjectPreviewMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
CardViewCard card = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject, typeof(CardViewCard), false) as CardViewCard;
if (card != null)
{
DataRecord record = card.DataContext as DataRecord;
if (record != null)
{
record.DataPresenter.ActiveRecord = record;
}
}
}
}
1
我已經有了一個解決方案已經:
/// <summary>
/// selects XamDataCards'es card on right button mouse down even
/// </summary>
public class XamDataCardsSelectCardOnRightMouseClickBehavior : Behavior<XamDataCards>
{
protected override void OnAttached()
{
AssociatedObject.PreviewMouseRightButtonDown += AssociatedObjectPreviewMouseRightButtonDown;
}
/// <summary>
/// select a card on right-click so that a context menu can be displayed
/// </summary>
/// <param name="sender">not used</param>
/// <param name="e">contians mouse position</param>
private void AssociatedObjectPreviewMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
VisualTreeHelper.HitTest(this.AssociatedObject, t => HitTestFilterBehavior.Continue, HitTestResultFunc, new PointHitTestParameters(e.GetPosition((UIElement)sender)));
}
/// <summary>
/// WPF invokes this method to report hit test intersections to the user.
/// If a card was hit, it is set as active (or selected) card.
/// </summary>
/// <param name="result">Contains the visual object that was hit.</param>
/// <returns>Always returns Continue.</returns>
public HitTestResultBehavior HitTestResultFunc(HitTestResult result)
{
DependencyObject dobj = result.VisualHit;
if (VisualTreeHelper.GetParent(dobj).GetType() == typeof(Infragistics.Windows.DataPresenter.DataRecordPresenter))
{
DataRecordPresenter rp = (DataRecordPresenter) VisualTreeHelper.GetParent(dobj);
this.AssociatedObject.ActiveDataItem = rp.DataRecord.DataItem;
}
return HitTestResultBehavior.Continue;
}
}
,然後簡單地將其連接到您的XamDataCards控制。
+0
我增加了一個行爲會激活記錄時,一個網格的標頭,除了數據是正確的點擊卡的一部分。 – alhalama
相關問題
- 1. 檢測從類選擇器中單擊鼠標右鍵?
- 2. 用鼠標右鍵單擊以選擇datagridview行
- 3. 無法用鼠標右鍵單擊並使用Selenium Webdriver選擇一個值
- 4. 想要鼠標右鍵單擊ToolStripMenuItem - C#
- 5. 右鍵單擊鼠標事件錯誤
- 6. 鼠標右鍵單擊WindowsUI的DevExpress
- 7. g_signal_connect用於單擊鼠標右鍵?
- 8. Datagrid +鼠標右鍵單擊事件
- 9. 用鼠標右鍵單擊NSStatusItem
- 10. 如何更改鼠標左鍵單擊和右鍵單擊選項?
- 11. 調用從鍵盤右鍵單擊鼠標右箭頭的keydown
- 12. 只允許通過在ListBox中單擊鼠標右鍵來選擇項目
- 13. 如何用鼠標右鍵點擊選擇textarea中的文字
- 14. 鼠標右鍵單擊事件右鍵單擊事件調用取消過程
- 15. 允許單擊鼠標左鍵單擊鼠標右鍵或按Ctrl鍵單擊打開對話框
- 16. 在WebBuild上點擊鼠標右鍵
- 17. Infragistics Ultragrid中的鼠標中鍵單擊功能
- 18. 在PHPStorm中鼠標右鍵單擊快捷鍵
- 19. DataGrid中的右鍵單擊選擇
- 20. 右鍵單擊以選擇文本JTextPane
- 21. 選擇右鍵單擊的TreeViewItem
- 22. 如何區分左鍵單擊,在pygame中單擊鼠標右鍵?
- 23. jtree右鍵單擊只選擇一個節點
- 24. 用鼠標右鍵單擊一個圖像,禁用其他圖像點擊
- 25. 在鼠標右鍵單擊事件中添加自定義菜單選項
- 26. QTableWidget的選擇多個小區鼠標右鍵
- 27. 鼠標:禁用右鍵和中鍵單擊
- 28. clearInterval同時單擊鼠標左鍵和右鍵不起作用
- 29. jQuery的點擊鼠標右鍵格
- 30. 鼠標右鍵點擊Openlayer 3
是的,這個解決方案比我的好多了,謝謝。 –