0

I have the following XAML inside a <TabItem>:

<ScrollViewer ....>
    <Border ....>
        <DockPanel ...>
        ....
        </DockPanel>
    </Border>
</ScrollViewer>

This same XAML is going to repeated multiple times. I'm wondering if it would be easier to create some type of UserControl or custom control (not sure user control will work). Then, if I need to change a setting on one of those 3 it would cascade to all TabItems that contain the ScrollViewer/Border/DockPanel.

Anatoliy Nikolaev
  • 22,370
  • 15
  • 69
  • 68
B-Rad
  • 1,519
  • 5
  • 17
  • 32

1 Answers1

1

You can put the abouve XAML code into a UserControl for instance, but you need to know that each time you use the user control, a diferent instace will be created. So if you want update all instaces you need to make a binding to a common INotifyPropertyChanged class property.

Hope this could helps...

Raúl Otaño
  • 4,640
  • 3
  • 31
  • 65
  • One thing I've struggled with in WPF is Panels and UserControls. When I put a panel in a user control and then try and use that UserControl in MainWindow.xaml, I can't have more than one child to the user control because content can only be set once. – B-Rad Mar 06 '13 at 18:52
  • 1
    In WPF are two main type of controls: items controls and content controls, items controls can have several children instead content control only have one. Window is a ContentControl, so you need to set an items control in the Window.Content property, also you can set a Panel like a grid, stack panel, wrap panel, or dock panel to set sever items into a window. – Raúl Otaño Mar 06 '13 at 19:02
  • I've created a UserControl with my DockPanel. Could you point me to an example of what you are talking about? – B-Rad Mar 06 '13 at 19:28
  • The answer [here](http://stackoverflow.com/questions/9094486/adding-children-to-usercontrol) worked great. – B-Rad Mar 06 '13 at 20:01