Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to create tab-able content in WPF/C#?
- <Page.DataContext>
- <Samples:TabBindingViewModels />
- </Page.DataContext>
- <Grid>
- <Grid.Resources>
- <DataTemplate x:Key="ContentTemplate"
- DataType="{x:Type Samples:TabBindingViewModel}">
- <TextBlock Text="{Binding Content}"/>
- </DataTemplate>
- </Grid.Resources>
- <TabControl ContentTemplate="{StaticResource ContentTemplate}"
- DisplayMemberPath="Header" ItemsSource="{Binding Items}" />
- </Grid>
- public class TabBindingViewModels
- {
- public TabBindingViewModels()
- {
- Items = new ObservableCollection<TabBindingViewModel>
- {
- new TabBindingViewModel(1),
- new TabBindingViewModel(2),
- new TabBindingViewModel(3),
- };
- }
- public IEnumerable<TabBindingViewModel> Items { get; private set; }
- }
- public class TabBindingViewModel
- {
- public TabBindingViewModel() : this(0)
- {
- }
- public TabBindingViewModel(int n)
- {
- Header = "I'm the header: " + n.ToString(CultureInfo.InvariantCulture);
- Content = "I'm the content: " + n.ToString(CultureInfo.InvariantCulture);
- }
- public string Header { get; set; }
- public string Content { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment