第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

用戶控件依賴屬性未更新

用戶控件依賴屬性未更新

C#
精慕HU 2021-10-24 19:21:00
我為 livechart 創(chuàng)建了一個(gè)用戶控件,并嘗試圍繞它創(chuàng)建依賴屬性。但是依賴屬性沒有得到更新。我用谷歌搜索并在 StackOverflow 中找到了答案。所以我一直在四處尋找。我按照答案中提到的步驟操作,但仍然無法更新圖表。代碼:-<LiveChart:CartesianChart Grid.Row="1" Background="White">        <LiveChart:CartesianChart.AxisX>            <LiveChart:Axis Title="{Binding Path=XAxisTitle, ElementName=chartControl, UpdateSourceTrigger=PropertyChanged}" Labels="{Binding Path=XAxisValues, ElementName=chartControl, UpdateSourceTrigger=PropertyChanged}"/>        </LiveChart:CartesianChart.AxisX>        <LiveChart:CartesianChart.AxisY>            <LiveChart:Axis Title="{Binding Path=YAxisTitle, ElementName=chartControl, UpdateSourceTrigger=PropertyChanged}" LabelFormatter="{Binding Path=Formatter, ElementName=chartControl, UpdateSourceTrigger=PropertyChanged}" MinValue="0"></LiveChart:Axis>        </LiveChart:CartesianChart.AxisY>        <LiveChart:CartesianChart.Series>            <LiveChart:LineSeries Values="{Binding Path=SpectrumChartSeries, ElementName=chartControl, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"></LiveChart:LineSeries>        </LiveChart:CartesianChart.Series>    </LiveChart:CartesianChart>我將用戶控件命名為 chartControl 并使用了 ElementName。我的后端:-public List<Point> ChartPoints    {        get { return (List<Point>)GetValue(ChartPointsProperty); }        set { SetValue(ChartPointsProperty, value); }    }    public static readonly DependencyProperty ChartPointsProperty = DependencyProperty.Register("ChartPoints", typeof(List<Point>), typeof(chartcontrol), new FrameworkPropertyMetadata(new List<Point>(), onChartrPointChange));    private static void onChartrPointChange(DependencyObject d, DependencyPropertyChangedEventArgs e)    {        var control = d as chartcontrol;        var points = e.NewValue as List<Point>;        control.UpdateChart(points);    }更改的事件被命中并且值被更新。但仍然沒有反映在圖表中。所以有點(diǎn)困惑。問題是當(dāng)我嘗試使用WPF 工具 Snoop并單擊線系列時(shí),我可以看到圖表立即更新,點(diǎn)擊前:-點(diǎn)擊后:-
查看完整描述

1 回答

?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

發(fā)布答案,以便它可以幫助像我這樣的人。我能夠找到這個(gè)博客幫助我的答案。正如他們所提到的,我需要在 Xaml 中添加數(shù)據(jù)上下文。


LiveChart:CartesianChart Grid.Row="1" Background="White" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:LiveChartControl}}">

        <LiveChart:CartesianChart.AxisX>

            <LiveChart:Axis Title="{Binding Path=XAxisTitle, Mode=TwoWay}" Labels="{Binding Path=XAxisValues, Mode=TwoWay}" MinValue="0"/>

        </LiveChart:CartesianChart.AxisX>

        <LiveChart:CartesianChart.AxisY>

            <LiveChart:Axis Title="{Binding Path=YAxisTitle, Mode=TwoWay}" LabelFormatter="{Binding Path=Formatter, Mode=TwoWay}" MinValue="0"></LiveChart:Axis>

        </LiveChart:CartesianChart.AxisY>

        <LiveChart:CartesianChart.Series>

            <LiveChart:LineSeries Values="{Binding Path=ChartPointsInChartValues, Mode=TwoWay}"/>

            <LiveChart:VerticalLineSeries Values="{Binding Path=EnergyLineChartValues , Mode=TwoWay}"/>

        </LiveChart:CartesianChart.Series>

    </LiveChart:CartesianChart>

這現(xiàn)在開始起作用了。


查看完整回答
反對(duì) 回復(fù) 2021-10-24
  • 1 回答
  • 0 關(guān)注
  • 274 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)