[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Collapse]Charts Suite
   [Collapse]Chart Control
    [Expand]Getting Started
    [Expand]Providing Data
    [Expand]Chart Elements
    [Expand]Appearance Customization
    [Expand]End-User Features
    [Expand]Design-Time Features
     [Expand]2D Chart Types
     [Expand]3D Chart Types
     [Expand]Providing Data
     [Expand]Data Representation
     [Expand]Chart Elements
     [Expand]Appearance Customization
     [Collapse]End-User Interaction
       How to: Determine which Chart Element is Hovered by the Mouse Pointer
       How to: Display Custom Tooltips for Series Points
       How to: Animate Series Points in a 3D Chart
       How to: Animate a 3D Chart Series
       How to: Animate a 3D Chart Diagram
       How to: Animate Series Points in a 2D Chart
       How to: Animate Series Templates
       How to: Create a Movable Legend at Runtime
       How to: Display a Custom Cursor in the Chart Control
       How to: Invoke the Chart Designer at Runtime
       How to: Implement Selection in the MVVM Style
    [Expand]Additional Resources
   [Expand]Chart3D Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Create a Movable Legend at Runtime

This example shows how to provide the capability for end-users to move a chart's legend at runtime.

For this, you need to assign a TranslateTransform object (named legendTransform) to the Legend.RenderTransform property. This allows you to control and modify a legend position.

Before changing a legend position, you should handle the ChartControl.MouseLeftButtonDown and ChartControl.MouseLeftButtonUp events to make sure that a legend has been dragged by a mouse. After that, it becomes possible to calculate a distance by which a legendTransform object should be moved. To accomplish this task, handle the ChartControl.MouseMove event.

Is this topic helpful?​​​​​​​