Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista Tutorial - Expose Inner Control of WPF Control

 
 
Old 01-19-2009   #1 (permalink)
Martin Robins
Guest


 
 

Expose Inner Control of WPF Control

I have a WPF control (derived from System.Windows.Controls.Control) that I
am creating, it will be used to apply a common look and feel to a form.
I have defined the XAML (in Generic.xaml) as follows...

<Style TargetType="{x:Type localialog}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type localialog}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<DockPanel Grid.Row="0" Margin="5">
<TabControl Name="PART_TabControl">
</TabControl>
</DockPanel>
<DockPanel Grid.Row="1" LastChildFill="False"
HorizontalAlignment="Right" Margin="5">
<Button IsDefault="True">OK</Button>
<Button IsCancel="True">Cancel</Button>
</DockPanel>

</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

What I would like to do is to expose the TabControl as a property of my
control so that I can use it as follows...

<controlsialog>
<controlsialog.TabControl>
<TabItem Header="Tab #1">
<TextBlock Text="Hello"></TextBlock>
</TabItem>
<TabItem Header="Tab #2">
<TextBlock Text="World"></TextBlock>
</TabItem>
</controlsialog.TabControl>
</controlsialog>

Please note that the usage above is only an example, I may also want to
access other properties of the TabControl and as such, merely binding the
ItemsSource property of the TabControl to an ObservableCollection<TabItem>,
while it addresses the specific example above, does not provide all of the
functionality that I would like.

Does anybody have any suggestions as to how I might achieve this?

Thanks.



My System SpecsSystem Spec
 

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46