Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Movable legend in WPF

Hi all,

I would like to have the legend(s) of my graph(s) movable in a WPF project, in form of clicking and dragging it around on top of the graph control. From this topic, there is an example for WinForms, which does not work with WPF. What would be the 'best practice' to implement this? In my project, I have a several graph controls and their according legends placed together in one grid cell. I found some topics of dragging UIElements with the help of the Thumb class, but this works only with Canvas and I could not get any good solution with that. I would appreciate any help.

Thanks

0 Kudos
Message 1 of 2
(2,449 Views)

Yes, in Windows Forms everything implicitly used canvas layout, whereas WPF gives you more granular control over content layout. To support dragging in a panel-independent fashion, you could use the Thumb example and set WPF properties like Margin (rather than Canvas.Left/Canvas.Top), or set a TranslateTransform, to re-position the graph legend.

~ Paul H
0 Kudos
Message 2 of 2
(2,411 Views)