我在我的Windows Phone 8.1 winrt應用程序中使用WinRTXamlToolkit.Controls.DataVisualization.Charting
。WinRTXamlToolkit.Controls.DataVisualization.Charting無法在.appx軟件包上工作
圖表在手機中的調試模式下正常工作。
但是,當我嘗試創建應用程序包,並在我的手機中使用部署工具安裝相同的,在這種情況下,圖表不起作用。
應用程序沒有崩潰,但帶有圖表控件的頁面未打開。
請找到下面的代碼
<Charting:Chart Name="LineChart"
Grid.Column="1"
Margin="0">
<Charting:Chart.LegendStyle>
<Style TargetType="datavis:Legend">
<Setter Property="Width"
Value="0" />
</Style>
</Charting:Chart.LegendStyle>
<Charting:Chart.Axes>
<Charting:CategoryAxis Orientation="X"
Location="Bottom"
Title="{Binding x_axis}"
ShowGridLines="True"
Foreground="{StaticResource DarkGrayBrush}"
x:Name="xAxis">
<Charting:CategoryAxis.TitleStyle>
<Style TargetType="datavis:Title">
<Setter Property="FontSize"
Value="16" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="Margin"
Value="0,10,0,0" />
</Style>
</Charting:CategoryAxis.TitleStyle>
<Charting:CategoryAxis.AxisLabelStyle>
<Style TargetType="Charting:AxisLabel">
<Setter Property="Foreground"
Value="{StaticResource DarkGrayBrush}"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Charting:AxisLabel">
<TextBlock Text="{TemplateBinding FormattedContent}"
TextAlignment="Right"
TextWrapping="Wrap"
Width="50"
Margin="-40,-5,0,26"
RenderTransformOrigin="1,.5">
<TextBlock.RenderTransform>
<RotateTransform Angle="300" />
</TextBlock.RenderTransform>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Charting:CategoryAxis.AxisLabelStyle>
<Charting:CategoryAxis.GridLineStyle>
<Style TargetType="Line">
<Setter Property="Stroke"
Value="{StaticResource GreyBrush}" />
<Setter Property="StrokeDashArray"
Value="2" />
</Style>
</Charting:CategoryAxis.GridLineStyle>
</Charting:CategoryAxis>
<Charting:LinearAxis Orientation="Y"
x:Name="yAxis"
Foreground="{StaticResource DarkGrayBrush}"
Title="{Binding y_axis}"
ShowGridLines="True">
<Charting:LinearAxis.TitleStyle>
<Style TargetType="datavis:Title">
<Setter Property="FontSize"
Value="16" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="Margin"
Value="10" />
</Style>
</Charting:LinearAxis.TitleStyle>
<Charting:LinearAxis.AxisLabelStyle>
<Style TargetType="Charting:AxisLabel">
<Setter Property="Foreground"
Value="{StaticResource DarkGrayBrush}"></Setter>
</Style>
</Charting:LinearAxis.AxisLabelStyle>
<Charting:LinearAxis.GridLineStyle>
<Style TargetType="Line">
<Setter Property="Stroke"
Value="{StaticResource GreyBrush}" />
<Setter Property="StrokeDashArray"
Value="2" />
</Style>
</Charting:LinearAxis.GridLineStyle>
</Charting:LinearAxis>
</Charting:Chart.Axes>
<Charting:ColumnSeries Margin="0"
IndependentValuePath="label"
IsSelectionEnabled="True"
DependentValuePath="refilled">
<Charting:ColumnSeries.DataPointStyle>
<Style TargetType="Charting:ColumnDataPoint">
<Setter Property="Background"
Value="{StaticResource columnBrush}" />
</Style>
</Charting:ColumnSeries.DataPointStyle>
</Charting:ColumnSeries>
<Charting:LineSeries Margin="0"
IndependentValuePath="label"
DependentValuePath="text"
IsSelectionEnabled="True">
<Charting:LineSeries.PolylineStyle>
<Style TargetType="Polyline">
<Setter Property="StrokeThickness"
Value="2" />
<Setter Property="Stroke"
Value="{StaticResource BrownBrush}" />
</Style>
</Charting:LineSeries.PolylineStyle>
<Charting:LineSeries.DataPointStyle>
<!--<Style TargetType="Charting:LineDataPoint">
<Setter Property="Background"
Value="{StaticResource BrownBrush}" />
<Setter Property="BorderThickness"
Value="1" />
</Style>-->
<Style TargetType="Control">
<Setter Property="Width"
Value="10" />
<Setter Property="Height"
Value="10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Charting:LineDataPoint">
<Grid Opacity="1"
ToolTipService.Placement="Left"
ToolTipService.ToolTip="test">
<Ellipse StrokeThickness="1"
Fill="{StaticResource BrownBrush}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Charting:LineSeries.DataPointStyle>
</Charting:LineSeries>
</Charting:Chart>
下面是C#代碼
(LineChart.Series[1] as LineSeries).ItemsSource = listItem;
(LineChart.Series[0] as ColumnSeries).ItemsSource = listItem;
分享你圖表控制xaml。 –
@MuhammadSaifullah請查看附件代碼 –
我有同樣的問題。你有沒有發現問題是什麼? – Greg