Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コードビハインドを介してStandardStyles.xamlで定義されたスタイルを割り当てようとしています。
私は試した
var x = Resources["UnfavoriteAppBarButtonStyle"];
しかし、そのコードでCOMExceptionが発生します。
COMコンポーネントの呼び出しからエラーHRESULTE_FAILが返されました。
上記のコードが間違っている場合、StandardStyles.xamlからスタイルにアクセスするにはどうすればよいですか?
わかった
それを行う正しい方法は次のとおりです。
var style = Application.Current.Resources["FavoriteAppBarButtonStyle"] as Style
この方法で追加することもできます
backButton.Style = (Style)this.Resources["NavigationBackButtonNormalStyle"];
ここ(style)でスタイルタイプとして宣言します
(style)