WPF - Application.Resourceを取得

Application.Resourceを取得

指定したキーを持つ ユーザー インターフェイス (UI) リソース (Style や Brush など) を検索します。

void findResourceButton_Click(object sender, RoutedEventArgs e) {
  try {
    object resource = Application.Current.FindResource("UnfindableResource");
  }
  catch (ResourceReferenceKeyNotFoundException ex) {
    MessageBox.Show("Resource not found.");
  }
}