Silverlight 2 Beta 1から Beta 2への変更点 - プロパティ値の継承
以前のこちらの投稿で、Silverlight 2 Beta 1にはプロパティ値の継承がないということを紹介しましたが、Beta 2ではその部分が変更されています。
以下は以前の投稿で使用したXAMLとまったく同じものです。
XAML(Silverlight)
<UserControl x:Class="SilverlightPropertyValueInheritance.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="300" Height="100">
<Grid>
<Button FontSize="36">
<TextBlock Text="36ポイントにはならない" />
</Button>
</Grid>
</UserControl>
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="300" Height="100">
<Grid>
<Button FontSize="36">
<TextBlock Text="36ポイントにはならない" />
</Button>
</Grid>
</UserControl>
Beta 1で実行した結果
Beta 2で実行した結果
このようにBeta 1では値が継承されていなかったFontSizeプロパティが、Beta 2では継承されるようになっています。WPFとの互換性が1つ向上したと言えるのではないでしょうか。
しかしながら、WPFと異なり値を継承する独自のカスタムプロパティを作ることはできないようです。Beta 2のDependencyProperty.RegisterAttachedメソッドを見てみますと、引数に直接PropertyChangedCallbackを渡すものからPropertyMetadataを渡すものへと変更はされていますが、WPFのようにFrameworkPropertyMetadataクラスは存在していません。
WPF
- RegisterAttached(String, Type, Type)
- RegisterAttached(String, Type, Type, PropertyMetadata)
- RegisterAttached(String, Type, Type, PropertyMetadata, ValidateValueCallback)
Silverlight 2 Beta 1
- RegisterAttached(String, Type, Type, PropertyChangedCallback)
Silverlight 2 Beta 2
- RegisterAttached(String, Type, Type, PropertyMetadata)
また、DependencyProperty.AddOwnerメソッドもありません。
08/06/16追記:
Beta 2でも、TextBoxコントロールだけはFontSizeプロパティの値を継承しないことを確認しています。なお、DataGridTextColumnも同様です。