GoWPF 3.0.3 - How to override the dragselection template

Hi, i am able to change the color of the rectangle in the overview by setting a BoxTemplate on the overview in XAML.

What i want to achieve is, to do the same for the diagram itself too. - Dont want a Magenta rectangle.

In the Generics.xaml if found those two templates:

  <DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type go:Diagram}, ResourceId=DefaultDragSelectingBoxTemplate}">
    <Rectangle Stroke="Magenta" StrokeThickness="1" go:Node.Selectable="False" go:Node.LayerName="Tool" />

  <DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type go:Diagram}, ResourceId=DefaultDragZoomingBoxTemplate}">
    <Rectangle Stroke="Magenta" StrokeThickness="1" go:Node.Selectable="False" go:Node.LayerName="Tool" />

My problem is, i dont know where i can set them? - Or better said, how can i apply a new template for the drag-selection?

You want to customize the DragSelectingTool and the DragZoomingTool that your Diagram uses. Do something like:

<go:Diagram . . .>
        <go:DragSelectingTool BoxTemplate="{StaticResource ...}" />
    . . .

and the same for <go:Diagram.DragZoomingTool>

Hi Walter.

Thanks for pointing at that direction. - The thing is, that i work with custom derivations.

<cus:CustomDiagram . . .>
        <cus:CustomDragSelectingTool BoxTemplate="{StaticResource ...}" />
    . . .

Primarily, this is because i want to educate myself how stuff is working.

I bind the Model in the XAML of CustomDiagram, and also set HasDefaultModel to false, otherwise Links from the LinksSource are not shown/rendered. - This however also leads to, that tools which i use define in XAML directly are not used. - I think this is a timing issue of GoWPF.

Anyway, i create all my custom tools within my CustomDiagrams constructor. - With that, it seems the tools are the ones that are actually used. - Only with that way, i hit breakpoints on some overwritten stuff.

I was able to create the BoxTemplate within the CustomDragSelectionTool’s constructor:

So for me this is solved now. - Still find it strange, that the Diagram behaves strange when used with MvvM binding mechanism’s. - There seems to be some kind of order someone has to follow to get the diagram working as expected.

Yes, that’s a problem with the Diagram constructor also creating all of those other objects that are associated with it by default.

I’m surprised you couldn’t use a regular XAML reference to the box template.