我想使用WinRTXamlToolkit.Controls.DataVisualization.UWPUWP StackedLineSeries不顯示值
企圖拉攏任何堆疊的圖表所示:
但僅此來出:
請幫助我,我不得不使用堆疊系列,但該框架不一個ct,因爲它應該是..
我想使用WinRTXamlToolkit.Controls.DataVisualization.UWPUWP StackedLineSeries不顯示值
企圖拉攏任何堆疊的圖表所示:
但僅此來出:
請幫助我,我不得不使用堆疊系列,但該框架不一個ct,因爲它應該是..
由於我不知道如何定義背後的代碼,我只提供瞭如下示例代碼,可以成功創建StackedLineSeries
圖表。
XAML代碼
<Page
x:Class="CStackLineChat.MainPage"
...
xmlns:charting="using:WinRTXamlToolkit.Controls.DataVisualization.Charting"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="50" >
<charting:Chart x:Name="MyChart" Title="Stacked column Chart">
<charting:StackedLineSeries>
<charting:StackedLineSeries.SeriesDefinitions>
<charting:SeriesDefinition
DependentValuePath="Amount"
IndependentValuePath="Name"
IsTapEnabled="True"
Title="Doodad" />
<charting:SeriesDefinition
Title="Stan2"
DependentValuePath="Amount"
IndependentValuePath="Name"/>
</charting:StackedLineSeries.SeriesDefinitions>
</charting:StackedLineSeries>
</charting:Chart>
</Grid>
</Page>
代碼背後
public sealed partial class MainPage : Page
{
private Random _random = new Random();
List<NameValueItem> Records = new List<NameValueItem>();
List<NameValueItem> Records2 = new List<NameValueItem>();
public MainPage()
{
this.InitializeComponent();
for (int i = 0; i < 5; i++)
{
Records.Add(new NameValueItem { Name = "Name" + i, Amount = _random.Next(10, 100) });
Records2.Add(new NameValueItem { Name = "Name" + i, Amount = _random.Next(10, 100) });
}
this.RunIfSelected(this.MyChart,() => ((StackedLineSeries)this.MyChart.Series[0]).SeriesDefinitions[0].ItemsSource = Records);
this.RunIfSelected(this.MyChart,() => ((StackedLineSeries)this.MyChart.Series[0]).SeriesDefinitions[1].ItemsSource = Records2);
}
private void RunIfSelected(UIElement element, Action action)
{
action.Invoke();
}
}
public class NameValueItem
{
public string Name { get; set; }
public int Amount { get; set; }
}
此外,通過在我身邊的測試,它似乎像DependentValuePath
和IndependentValuePath
屬性不能直接綁定在你的場景中。使用此軟件包的最佳方法是遵循official sample。 Here是圖表示例。
謝謝! 它的工作方式是這樣(代碼背後),但會在MVVM模式中使用它,因此將其綁定到ViewModel中的屬性。 正如我在圖表中看到的那樣,開發人員不在堆疊圖表中使用綁定,只有在簡單的...也許是因爲它不被支持? btw感謝您的幫助,我會深入檢查這個示例。 – Colosh
@Farkangyal其實我不能說通過官方文檔是否支持很差。作爲我的測試,綁定不起作用。請嘗試做更多關於'DependentValueBinding'的測試。對於新問題,您可以打開新的幫助線索。謝謝。 –
您是否在Visual Studio的「輸出」選項卡中檢查了綁定錯誤? – ibebbs
是的,沒有綁定錯誤。 – Colosh
您是否嘗試將綁定模式更改爲OneWay? {綁定記錄,模式=單向} –