を見つけることができる「トップ」の定義とタイプ「グリッド」の最初の引数を受け入れていない 拡張メソッド「トップ」を含みませんWindows 10 Anniversary Update SDK(14393)で修正されています。
私たちが知っているように、{x:Bind}は、その利点を達成するために生成コードを使用します。 XAMLコンパイル時に{x:Bind}
はコードに変換され、データソースのプロパティから値を取得し、マークアップで指定されたプロパティに設定します。
すると、アプリのターゲット14393より前のバージョンでは、それが結合双方向を更新するには、次のようなコードを生成します。
this.obj2 = (global::Windows.UI.Xaml.Controls.Grid)target;
(this.obj2).RegisterPropertyChangedCallback(global::Windows.UI.Xaml.Controls.Canvas.LeftProperty,
(global::Windows.UI.Xaml.DependencyObject sender, global::Windows.UI.Xaml.DependencyProperty prop) =>
{
if (this.initialized)
{
// Update Two Way binding
this.dataRoot.PositionX = (this.obj2).Left;
}
});
(this.obj2).RegisterPropertyChangedCallback(global::Windows.UI.Xaml.Controls.Canvas.TopProperty,
(global::Windows.UI.Xaml.DependencyObject sender, global::Windows.UI.Xaml.DependencyProperty prop) =>
{
if (this.initialized)
{
// Update Two Way binding
this.dataRoot.PositionY = (this.obj2).Top;
}
});
obj2
はGrid
あり、それはLeft
またはTop
というプロパティが含まれているので、私たちはありませんコンパイラエラーが発生します。
この問題を解決するには、アプリの最小ターゲットSDKのバージョンが14393以降である必要があります。 Visual Studioですでに作成されているプロジェクトの最小およびターゲットバージョンを変更するには、プロジェクト→プロパティ→アプリケーションタブ→ターゲットに移動します。この後
、我々はその後、何のコンパイラエラーがあってはならない、プロジェクトを再構築することができます。バインドは正しく生成される必要があります。
this.obj2 = (global::Windows.UI.Xaml.Controls.Grid)target;
(this.obj2).RegisterPropertyChangedCallback(global::Windows.UI.Xaml.Controls.Canvas.LeftProperty,
(global::Windows.UI.Xaml.DependencyObject sender, global::Windows.UI.Xaml.DependencyProperty prop) =>
{
if (this.initialized)
{
// Update Two Way binding
this.dataRoot.PositionX = global::Windows.UI.Xaml.Controls.Canvas.GetLeft(this.obj2);
}
});
(this.obj2).RegisterPropertyChangedCallback(global::Windows.UI.Xaml.Controls.Canvas.TopProperty,
(global::Windows.UI.Xaml.DependencyObject sender, global::Windows.UI.Xaml.DependencyProperty prop) =>
{
if (this.initialized)
{
// Update Two Way binding
this.dataRoot.PositionY = global::Windows.UI.Xaml.Controls.Canvas.GetTop(this.obj2);
}
});
問題を再現できる[mcve]を共有できますか? –
@ JayZuo-MSFTはい、私は – SmiLe
を投稿しました。あなたが投稿したコードでテストしましたが、私の側にコンパイラエラーはありません。あなたが投稿したコードに問題がないかもしれません。新しい空のアプリケーションプロジェクトでコードを試すことができます。それでも問題が解決しない場合は、[mcve]を共有してください。 –