在C#wpf中添加滑块上的直方图

时间:2014-07-30 05:51:03

标签: c# wpf rad-controls

如何使用C#WPF在Radslider上绘制直方图,如下图所示?我在网上搜索但没有获得信息。

enter image description here

1 个答案:

答案 0 :(得分:1)

您好,

               <StackPanel  Grid.Column="1"  Margin="7,-72,7.5,0">
                     <telerik:RadCartesianChart Palette="Summer" >
                          <telerik:RadCartesianChart.HorizontalAxis>
                             <telerik:CategoricalAxis Visibility="Hidden"/>
                        </telerik:RadCartesianChart.HorizontalAxis>
                        <telerik:RadCartesianChart.VerticalAxis>
                         <telerik:LinearAxis Visibility="Hidden" MajorStep="20" />
                    </telerik:RadCartesianChart.VerticalAxis>
                    <telerik:RadCartesianChart.Series>
                        <telerik:BarSeries ItemsSource="{Binding KeyValue, Mode=TwoWay}" CategoryBinding="Key" ValueBinding="Value">
                            <telerik:BarSeries.PointTemplates>
                                <DataTemplate>
                                    <Rectangle Width="3" Fill="SkyBlue"/>
                                </DataTemplate>
                            </telerik:BarSeries.PointTemplates>
                        </telerik:BarSeries>
                    </telerik:RadCartesianChart.Series>
                </telerik:RadCartesianChart>
            </StackPanel>

           <telerik:RadSlider Minimum="{Binding LowValue,Mode=TwoWay}"  Height="13" 
            Margin="5" Grid.Column="1" Maximum="{Binding HighValue,Mode=TwoWay}" 
            SelectionEnd="{Binding SelectionHigh,Mode=TwoWay}" 
            SelectionStart="  {Binding SelectionLow,Mode=TwoWay}"
            TickPlacement="TopLeft"  
            SelectionChanged="RadSlider_SelectionChanged" SelectionRangeEnabled="True" 
            IsDirectionReversed="False" SmallChange="10" VerticalAlignment="Bottom">                        
             </telerik:RadSlider>

您可以添加RadChart&amp ;;而不是自定义RadSlider。 RadSlider与我所示的列相同。 我只是将Xaml代码与绑定结合起来,现在你可以编写直方图的逻辑。