【问题标题】:'IndependentValue' member is not valid because it does not have a qualifying type name in chartinToolkit wpf“IndependentValue”成员无效,因为它在 chartinToolkit wpf 中没有限定类型名称
【发布时间】:2016-12-31 10:11:05
【问题描述】:

我正在尝试查看图表中 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>

请任何人帮助我 谢谢:)

【问题讨论】:

  • 问题主要出在 xaml 我解决了 thx :)

标签: wpf xaml charts tooltip wpftoolkit


【解决方案1】:

万一有人在这里搜索错误消息,我得到它只是因为我错误地使用x:Static 而不是StaticResource 来访问本地声明的资源。

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

【讨论】:

  • 看了你的回答后,我的头因为敲击键盘而受伤。让我开心:-)
  • 在我的情况下,样式声明中缺少 TargetType 道具...
【解决方案2】:

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

<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>

【讨论】:

  • 如果有人不理解这个解决方案,那是因为问题作者试图在ControlTemplate 之外使用TemplateBinding,应该使用这种特殊类型的绑定。因此,此解决方案是在 ControlTemplate 中使用它。
【解决方案3】:

以防有人需要眼镜,比如我..

之前(XAML 失败)

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

之后(固定 XAML)

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

我只需要将冒号改为点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-31
    • 1970-01-01
    • 2021-04-15
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多