Diagramm - Position der Legende

  • WPF

    Diagramm - Position der Legende

    Hallo Zusammen

    Ich bin was WPF betrifft ein absoluter Neuling.
    Ich möchte gerne ein Diagramm (habe mich für das Chart Toolkit entschieden) darstellen, bei welchem die Legende eine andere Position hat.

    Folgendes ist mein XAML Code

    XML-Quellcode

    1. <Window x:Name="ChartWindow1" x:Class="ChartWindow"
    2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4. xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    5. xmlns:dataVis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    6. xmlns:chartPrmtvs="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    7. Title="Sensor Chart" Height="600" Width="800" AllowDrop="True" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinHeight="600" MinWidth="800" ShowInTaskbar="False" SnapsToDevicePixels="True" WindowStartupLocation="CenterOwner">
    8. <Grid>
    9. <chartingToolkit:Chart Name="Chart1" Title="Sensor-Chart" Margin="0,0,183,0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto">
    10. <!--<chartingToolkit:Chart.Template>
    11. <ControlTemplate TargetType="chartingToolkit:Chart">
    12. <Grid>
    13. <Grid.RowDefinitions>
    14. <RowDefinition Height="Auto"/>
    15. <RowDefinition Height="*"/>
    16. <RowDefinition Height="Auto"/>
    17. </Grid.RowDefinitions>
    18. <dataVis:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}" />
    19. <Grid x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" Grid.Row="1">
    20. <Grid x:Name="PlotArea" Style="{TemplateBinding PlotAreaStyle}">
    21. <Grid x:Name="GridLinesContainer"/>
    22. <Grid x:Name="SeriesContainer"/>
    23. </Grid>
    24. </Grid>
    25. <dataVis:Legend x:Name="Legend" Style="{TemplateBinding LegendStyle}" Grid.Row="0"/>
    26. </Grid>
    27. </ControlTemplate>
    28. </chartingToolkit:Chart.Template>-->
    29. <chartingToolkit:Chart.LegendStyle>
    30. <Style TargetType="Control">
    31. <Setter Property="Width" Value="Auto"/>
    32. <Setter Property="Height" Value="Auto"/>
    33. <Setter Property="Background" Value="Transparent" />
    34. <Setter Property="BorderThickness" Value="0" />
    35. </Style>
    36. </chartingToolkit:Chart.LegendStyle>
    37. <chartingToolkit:Chart.Axes>
    38. <chartingToolkit:DateTimeAxis x:Name="XAxis" Orientation="X" ShowGridLines="False" Margin="0,0,0,-12" Height="36" VerticalAlignment="Bottom">
    39. <chartingToolkit:DateTimeAxis.AxisLabelStyle>
    40. <Style TargetType="chartingToolkit:DateTimeAxisLabel">
    41. <Setter Property="StringFormat" Value="{}{0:dd.MM.yyyy HH:mm:ss}"/>
    42. </Style>
    43. </chartingToolkit:DateTimeAxis.AxisLabelStyle>
    44. </chartingToolkit:DateTimeAxis>
    45. <chartingToolkit:LinearAxis Orientation="Y" ShowGridLines="True"/>
    46. </chartingToolkit:Chart.Axes>
    47. </chartingToolkit:Chart>
    48. </Grid>
    49. </Window>


    (Die Oberfläche ist natürlich noch nicht fertig!)

    Das Datenbinding mache ich dann im VB Code und das funktioniert einwandfrei.
    Jedoch möchte ich, dass die Legende oberhalb des Diagrammes (horizontal) ist, um möglichst wenig Platz wegzunehmen, wenn die Seriennamen länger werden!

    Ich kriege das einfach nicht hin. Klar ist, dass ich das Template ändern muss. Aber ich kriegs so nicht zum laufen. Kann mir da jemand helfen?


    Weiter möchte ich, dass ich auf der Oberfläche per Checkbox sagen kann, wie die X-Achse formattiert sein soll. Also Checkbox gesetzt, dann müsste das Format dd.MM.yyyy HH:mm:ss sein.
    Ist die Checkbox nicht gesetzt, dann brauche ich HH:mm:ss

    Vielen Dank für Eure Hilfe!
    Veronesi