'Remove Wpf Charting Legend
Can anyone help with wpf toolkit charting control?
I want to remove the legend beside my chart, but I can't find the solution. Please help thanks.
<Window x:Class="CSV_Reader.Histogram_for_2Pgs"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CSV_Reader"
mc:Ignorable="d"
Title="Histogram_for_2Pgs" SizeToContent="WidthAndHeight" ScrollViewer.CanContentScroll="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<chartingToolkit:Chart Height="350" Grid.Row="0" Grid.ColumnSpan="3"
Margin="10,10,10,15" x:Name="ColumnChart1" Title="{Binding}" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Width="800" >
<chartingToolkit:ColumnSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}"/>
</chartingToolkit:Chart>
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto" Margin="10" Width="Auto" Grid.Row="1" Grid.ColumnSpan="3">
<ListView x:Name="HistogramLabel" Height="Auto" Width="800" >
<ListView.View>
<GridView>
<GridViewColumn Header="Label" Width="50" DisplayMemberBinding="{Binding label}"/>
<GridViewColumn Header="Description" Width="auto" DisplayMemberBinding="{Binding description}" />
<GridViewColumn Header="Appear" Width="auto" DisplayMemberBinding="{Binding appear}" />
</GridView>
</ListView.View>
</ListView>
</ScrollViewer>
<Button x:Name="PrintWindow" Content="Print" HorizontalAlignment="Stretch" Grid.Row="2" Grid.Column="0" Padding="10" Margin="10" Click="PrintWindow_Click"/>
<Button x:Name="DescFilter" Content="Descending" HorizontalAlignment="Stretch" Grid.Row="2" Grid.Column="1" Padding="10" Margin="10" Click="Desc_Click"/>
<Button x:Name="AscFilter" Content="Ascending" HorizontalAlignment="Stretch" Grid.Row="2" Grid.Column="2" Padding="10" Margin="10" Click="Asc_Click"/>
</Grid>
I wanted to remove the legend in the red circle
Thanks in advance
Solution 1:[1]
For example:
xmlns:dv="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:dvc="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
<dvc:Chart.LegendStyle>
<Style TargetType="dv:Legend">
<Setter Property="Width" Value="0"></Setter>
</Style>
</dvc:Chart.LegendStyle>
Solution 2:[2]
I've tried ?????????? ????????'s solution, and seems not working. The issue is with "Width" property that it doesn't exists, so I edited the solution:
<DVC:Chart.LegendStyle>
<Style>
<Setter Property="DocumentViewerBase.Width" Value="0" />
</Style>
</DVC:Chart.LegendStyle>
This does the job properly for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ?????????? ???????? |
Solution 2 | radocz_sandor |