tags:

views:

501

answers:

1

I have a DesignerCanvas (derived from canvas) that I can add UIElements to, then drag\drop\move\group and move them around.

On the toolbar I have a button that is bound to a group command.

<Button Margin="0,3,0,3" Padding="5" HorizontalContentAlignment="Left"
        Command="{x:Static s:DesignerCanvas.Group}"
        CommandTarget="{Binding ElementName=DesignerCanvas}">

The problem that I have is that I can have a control that also contains a DesignerCanvas. So there are nested canvas's, and I want the GroupCommand on the toolbar to apply to the canvas that is in focus. In the above binding it is binding only to the root canvas.

I suppose I could track the current canvas and expose it in the viewmodel for the binding, but I'd prefer to avoid tracking the activecanvas.

Any suggestions for a creative binding here?

Thanks, jeff

+2  A: 

Is GroupCommand a RoutedCommand? Assuming it is, I would expect that you would get the behavior you want by removing the CommandTarget property assignment.

Daniel Pratt
Thanks. Works great.
jeff