SilverLight4用のMicrosoftLiveLabs PivotViewerコントロールの現在のバージョンには、コントロールの要素のスタイルを設定する方法がありません。Reflectorのコントロールを見ると、スタイル情報の多くがアセンブリのResourceDictionary(assets / defaultcolors.xaml)に設定されていることがわかります。私がやりたいのは、このファイルの独自のコピーを作成し、実行時にPivotViewerコントロールでそれを置き換えることです。
PivotViewerコントロールをサブクラス化し、OnApplyTemplateをオーバーライドすることで、子要素を取得し、Backgroundなどのプロパティを設定できます。私はMergedDictionariesをClear()'ngして、自分で追加することに成功していません。
public override void OnApplyTemplate() {
base.OnApplyTemplate();
/* can change things this way */
CollectionViewerView cvv = ((CollectionViewerView)((Grid)this.GetTemplateChild("PART_Container")).Children[0]);
((Grid)cvv.Content).Background = new SolidColorBrush(Colors.Black);
/* can't change things this way */
CustomDictionary gd = new CustomDictionary();
cvv.Resources.MergedDictionaries.Clear();
cvv.Resources.MergedDictionaries.Add(gd);
}