バインディングをシミュレートするカスタムMarkupExtensionがあります。スタイルセッターで使用する場合には、たとえば、通常の割り当てで正常に機能しますが、:XamlParseExceptionでカスタムWPFバインディング
<Setter Property="Content" Value="{local:MyExtension}" />
結果:
A 'Binding' cannot be set on the 'Value' property of type 'Setter'.
A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
これは、拡張機能の実装です:
何public class MyExtension : MarkupExtension
{
public MyExtension()
{
Value = 123;
}
public object Value
{
get;
set;
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
var binding = new Binding("Value")
{
Source = this,
};
return binding.ProvideValue(serviceProvider);
}
}
問題?!
「バインディング」は「フリーズ可能」ではありません。したがって、特別なサポート。 –