私はカスタムコントロールLineChart
を持っています。 xaml.csでコード:他のページでUWPカスタムコントロールのプロパティエラーに割り当てられませんでした
public Brush Abc
{
get { return new SolidColorBrush(new Color() {A = 123, B = 123, G = 23, R = 12 }); }
}
:
<controls:LineChart Stroke="{Binding Abc}" />
すべてのコードStroke="Green"
の静的行と正常に動作しますが、私は使用してビューモデルクラスで
public static readonly DependencyProperty StrokeProperty =
DependencyProperty.Register("StrokeProperty", typeof(Brush), typeof(LineChart), new PropertyMetadata(new SolidColorBrush(),
new PropertyChangedCallback(OnItemsChanged)));
public Brush Stroke
{
get { return (Brush)GetValue(StrokeProperty); }
set { SetValue(StrokeProperty, value); }
}
Binding
、プログラムがエラーで破損しました:
Windows.UI.Xaml.Markup.XamlParseException: The text associated with this error code could not be found.
Failed to assign to property CurrencyExchangeUniversal.App.Controls.LineChart.Stroke'. [Line: 102 Position: 41] at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation) at CurrencyExchangeUniversal.App.View.NationalBankPage.InitializeComponent() at CurrencyExchangeUniversal.App.View.NationalBankPage..ctor()
Abcのの種類は何ですか:最初の引数の値が
"Stroke"
、ない"StrokeProperty"
すべきですか? – Archana'Abc'のコードを追加しました –
Bindingのようですね。 OnItemsChangedメソッドのチェック – Archana