【问题标题】:Silverlight Chart ControlSilverlight 图表控件
【发布时间】:2011-04-14 02:31:41
【问题描述】:

我有一个 silverlight 图表,当用户单击其中一个系列项目时会发生一个事件。

甚至会关闭包含图表的面板并打开一个新面板,其中包含该系列项目的附加数据的数据网格。

完成此数据后,有一个后退按钮,用于关闭带有数据网格的面板并再次显示带有图表的面板。

我的问题是,当向用户显示图表时,它会保留原始选定的系列项目。有没有办法重置它,以便用户可以根据需要再次单击同一项目。

【问题讨论】:

    标签: silverlight charts


    【解决方案1】:

    如果要清除选择,可以将SelectedItem属性设置为null。

    简单图表举例:

        <Button Content="Clear" Click="Button_Click" HorizontalAlignment="Center" />
        <chart:Chart x:Name="chart" Grid.Row="1">
            <chart:Chart.Series>
                <chart:ColumnSeries IsSelectionEnabled="True" ItemsSource="{Binding}" IndependentValuePath="Year" DependentValuePath="Value" />
            </chart:Chart.Series>
        </chart:Chart>
    

    清除选择的代码:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var cs = (DataPointSeries)this.chart.Series[0];
        cs.SelectedItem = null;
    }
    

    我使用索引 0 因为我知道系列的位置,它是图表的第一个系列。

    我认为您的图表也有单个系列。

    【讨论】:

    • 优秀的正是我想要的。谢谢
    猜你喜欢
    • 2011-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多