WPF ToolBar: problem with CurrentItem

  • Thread starter Thread starter Haiping
  • Start date Start date
H

Haiping

Hello,

I need drag a ToolBar item into a window. I did the following
implementation. I don't know why the myToolBar.Items.CurrentItem is null. I
think the MouseMove event on a ToolBar should return me a ToolBar item.

In Xaml file:
<ToolBar x:Name="myToolBar" MouseMove="OnMyToolBar_MouseMove">

In Xaml.cs file:
private void OnMyToolBar_MouseMove(object sender, MouseEventArgs
theMouseEventArgs)
{
if (theMouseEventArgs.LeftButton == MouseButtonState.Pressed &&
(myToolBar.Items.CurrentItem != null))
{
}
}

Thanks for any inputs.
 
I found way to get around this problem. Instead of put MouseMove event
handle on ToolBar I put it in each ToolBar buttons. The drag and drop works
nicely.
 
Back
Top