“IndependentValue”成员无效,因为它在 ChartinToolkit wpf 中没有限定类型名称

问题描述 投票:0回答:4

我正在尝试查看图表中 ace 的值,但出现以下错误 “'IndependentValue' 成员无效,因为它在 ChartinToolkit wpf 中没有限定类型名称”

这是我的代码

    <Window x:Class="WpfToolkitChart.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="1031" Width="855" xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"  FlowDirection="RightToLeft">

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,-28,0,28">
    <Grid Height="500">

        <chartingToolkit:Chart  Name="lineChart" Title="Line Series Demo" VerticalAlignment="Top" Margin="33,6,6,0" Height="440" Foreground="DarkRed" FlowDirection="LeftToRight" FontFamily="CPalatineLinoType">
            <chartingToolkit:LineSeries  DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True"/>

            <ToolTipService.ToolTip>
                <StackPanel Margin="2,2,2,2">
                    <ContentControl Content="{TemplateBinding IndependentValue}" FontSize="12"/>
                    <ContentControl Content="{TemplateBinding DependentValue}"   FontSize="12"/>
                </StackPanel>
            </ToolTipService.ToolTip>
        </chartingToolkit:Chart>
    </Grid>
</ScrollViewer>

请有人帮我解决这个问题 谢谢:)

wpf xaml charts tooltip wpftoolkit
4个回答
22
投票

以防万一有人来到这里寻找错误消息,我收到它只是因为我错误地使用

x:Static
而不是
StaticResource
来访问本地声明的资源。

希望这对以后的人有帮助。


0
投票

以防有人像我一样需要眼镜..

之前(XAML 失败)

<Setter Property="Command" Value="{x:Static local:Map:ZoomCommand}" />

之后(修复了 XAML)

<Setter Property="Command" Value="{x:Static local:Map.ZoomCommand}" />

我只需要把冒号改成点。


0
投票

您看到此错误是因为您在控件模板之外使用

TemplateBinding
。您只能在控件模板中使用该绑定类型。

如果不向问题添加更多细节,我不确定您到底想实现什么目标。

您可以在

这个其他答案
中看到适当使用TemplateBinding的示例。


-1
投票

我已经通过这段代码解决了问题

<chartingToolkit:LineSeries.DataPointStyle>
    <Style TargetType="chartingToolkit:DataPoint">
        <Setter Property="Background" Value="#0077CC" />
        <Setter Property="BorderBrush" Value="White"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="chartingToolkit:LineDataPoint">
                    <Grid x:Name="Root" Opacity="1">
                        <ToolTipService.ToolTip>
                            <StackPanel Margin="2,2,2,2">
                                <ContentControl Content="{TemplateBinding IndependentValue}" ContentStringFormat="Date : {0}"/>
                                <ContentControl Content="{TemplateBinding DependentValue}" ContentStringFormat="Count : {0:###,###,###}"/>
                            </StackPanel>
                        </ToolTipService.ToolTip>
                        <Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</chartingToolkit:LineSeries.DataPointStyle>
© www.soinside.com 2019 - 2024. All rights reserved.