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.
App.xaml ファイル「tabControlStyle」で定義されたスタイルがあります。動的に作成された TabItem コントロールにこのスタイルを割り当てるにはどうすればよいですか。
TabItem item = new TabItem(); item.Header = String.Format("Item {0}", i); documentTab.Items.Add(item);
答えがわかりました。ここにあります:
private void PopulateTabControl() { for(int i=1; i<=10;i++) { TabItem item = new TabItem(); item.Style = Application.Current.Resources["tabItemStyle"] as Style; item.Header = String.Format("Item {0}", i); documentTab.Items.Add(item); } }