'IndependentValue'成员无效,因为在chartinToolkit wpf中没有合格的类型名称

sha*_*del 2 wpf charts xaml tooltip wpftoolkit

我正在尝试查看图表中的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>
Run Code Online (Sandbox Code Playgroud)

请在此感谢任何人帮助我:)

dot*_*NET 7

万一有人登陆这里搜索错误消息,我之所以得到它仅仅是因为我错误地使用了x:Static而不是StaticResource访问本地声明的资源。

希望这可以帮助某人。


sha*_*del -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>
Run Code Online (Sandbox Code Playgroud)

  • 如果有人不理解这个解决方案,那是因为问题作者尝试在“ControlTemplate”之外使用“TemplateBinding”,而应该使用这种特殊类型的绑定。因此,该解决方案是在“ControlTemplate”中使用它。 (6认同)