本文整理汇总了C#中System.Windows.Controls.ListBoxItem.SetCurrentValueInternal方法的典型用法代码示例。如果您正苦于以下问题:C# ListBoxItem.SetCurrentValueInternal方法的具体用法?C# ListBoxItem.SetCurrentValueInternal怎么用?C# ListBoxItem.SetCurrentValueInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ListBoxItem
的用法示例。
在下文中一共展示了ListBoxItem.SetCurrentValueInternal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeToggleSelection
private void MakeToggleSelection(ListBoxItem item)
{
bool select = !item.IsSelected;
item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.Box(select));
UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
}
示例2: NotifyListItemClicked
internal void NotifyListItemClicked(ListBoxItem item, MouseButton mouseButton)
{
// When a ListBoxItem is left clicked, we should take capture
// so we can auto scroll through the list.
if (mouseButton == MouseButton.Left && Mouse.Captured != this)
{
Mouse.Capture(this, CaptureMode.SubTree);
SetInitialMousePosition(); // Start tracking mouse movement
}
switch (SelectionMode)
{
case SelectionMode.Single:
{
if (!item.IsSelected)
{
item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.TrueBox);
}
else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
item.SetCurrentValueInternal(IsSelectedProperty, BooleanBoxes.FalseBox);
}
UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
}
break;
case SelectionMode.Multiple:
MakeToggleSelection(item);
break;
case SelectionMode.Extended:
// Extended selection works only with Left mouse button
if (mouseButton == MouseButton.Left)
{
if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift))
{
MakeAnchorSelection(item, false);
}
else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
MakeToggleSelection(item);
}
else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
{
MakeAnchorSelection(item, true);
}
else
{
MakeSingleSelection(item);
}
}
else if (mouseButton == MouseButton.Right) // Right mouse button
{
// Shift or Control combination should not trigger any action
// If only Right mouse button is pressed we should move the anchor
// and select the item only if element under the mouse is not selected
if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == 0)
{
if (item.IsSelected)
UpdateAnchorAndActionItem(ItemInfoFromContainer(item));
else
MakeSingleSelection(item);
}
}
break;
}
}