1
我目前正在與Telerik FW一起開發WPF項目。telerik:PieSeries綁定顏色CanFreeze警告
在我得到以下警告運行時:
System.Windows.Freezable Warning: 1 : CanFreeze is returning false because a DependencyProperty on the Freezable has a value that is an expression; Freezable='System.Windows.Media.TranslateTransform'; Freezable.HashCode='36319496'; Freezable.Type='System.Windows.Media.TranslateTransform'; DP='X'; DpOwnerType='System.Windows.Media.TranslateTransform'
這是我的XAML代碼
<Style x:Key="PieSliceStyle" TargetType="Path">
<Setter Property="Fill" Value="{Binding DataItem.Color}" />
</Style>
<telerik:PieSeries ItemsSource="{Binding Source}" DefaultSliceStyle="{StaticResource PieSliceStyle}">
<telerik:PieSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="Value" />
</telerik:PieSeries.ValueBinding>
<telerik:PieSeries.LabelDefinitions>
<telerik:ChartSeriesLabelDefinition Margin="-10">
<telerik:ChartSeriesLabelDefinition.Binding>
<telerik:PropertyNameDataPointBinding PropertyName="Label" />
</telerik:ChartSeriesLabelDefinition.Binding>
</telerik:ChartSeriesLabelDefinition>
</telerik:PieSeries.LabelDefinitions>
</telerik:PieSeries>
這是我的ViewModel的某些部分
private readonly SolidColorBrush PieColorEnableSlice = new SolidColorBrush(Colors.LightGray);
private readonly SolidColorBrush PieColorDisabledSlice = new SolidColorBrush(Colors.Red);
public AsyncObservableCollection<MSShareClassModel> List
{
get
{
return this._list;
}
set
{
if (this.SetProperty(ref this._list, value, "List"))
{
this.Source = new AsyncObservableCollection<PieChartModel>
{
new PieChartModel
{
Label = "Active",
Value = this._list.Count(x => x.Status == "1"),
Color = this.PieColorEnableSlice
},
new PieChartModel
{
Label = "Disable",
Value = this._list.Count(x => x.Status == "0"),
Color = this.PieColorDisabledSlice
},
};
}
}
}
我想一種解決方案是直接從xaml源創建corlor。 但我想保持此綁定,以便能夠以編程方式更改顏色。
有關此警告的任何想法?
Peharps使用DefaultSliceStyle一個DynamicResource:我已經讀過,它有助於解決這一警告...... –
這不會改變任何東西:/ DefaultSliceStyle =「{DynamicResource PieSliceStyle} 「> – pix