Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Expose Inner Control of WPF Control

24 views
Skip to first unread message

Martin Robins

unread,
Jan 19, 2009, 3:09:35 PM1/19/09
to
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 local:Dialog}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Dialog}">
<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...

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

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.


0 new messages