我需要找到<条码>在(rectangle/area/spanishs)中的“钥匙Element。
Main Window 我做以下工作:
- I register the mouse down as the start position.
- I regsiter the mouse up position.
- Now I need to find ll (buttons, textboxes, etc) in the rectangle between start postion and the end position.
I found in the msdn the HitTest
approach but it is only for one point. I think, walking through all points in the founded
rectangle it is a performance disaster.
我的守则以多国机器设备模式为基础:
private ObservableCollection<UIElementViewModel> wells;
private Point stratPoint; // Mouse down
public ICommand MouseUpRightCommand
{
get
{
if (this.mouseUpRightCommand == null)
{
this.mouseUpRightCommand = new RelayCommands(
param =>
{
if (param is MouseButtonEventArgs)
{
var e = (param as MouseButtonEventArgs);
//Set the end point
endPosition = e.GetPosition(((ItemsControl)e.Source));
// for example, here I want to find all controls(UIElements) in the
// founded rectangle of stratPoint and endPosition.
}
});
}
return this.mouseUpRightCommand;
}
}
任何其他想法或更好的做法?
成就