View Single Post
Old 07-14-2007   #2 (permalink)
Lloyd Dupont


 
 

Re: Headered custom control

I haven't look at your XAML, but I have an advice, take a look at the XAML
of the default controls (it really helps)!!

For that you should download Reflector and the BAML reader plugin, if you
haven't done it already.
Then use the BAML reader on PresentationFramework.aero.dll

"Jan Kucera" <miloush@community.nospam> wrote in message
news:9E6EC046-C164-4BDA-9937-413DF9E951D4@microsoft.com...
> Hi,
> so I'm creating a custom control in library, which inherits
> HeaderedItemsControl. But I can't manage the default templates to work.
> I'm trying something like this:
>
> <Style TargetType="{x:Type src:MyControl}">
> <Setter Property="HeaderTemplate">
> <Setter.Value>
> <DataTemplate DataType="{x:Type src:ConditionBuilderItem}">
> <TextBlock Foreground="{TemplateBinding Control.Foreground}"
> FontFamily="{TemplateBinding
> TextElement.FontFamily}"
> FontSize="{TemplateBinding
> TextElement.FontSize}"
> FontStretch="{TemplateBinding
> TextElement.FontStretch}"
> FontStyle="{TemplateBinding
> TextElement.FontStyle}"
> FontWeight="{TemplateBinding
> TextElement.FontWeight}"
> HorizontalAlignment="{TemplateBinding
> Control.HorizontalContentAlignment}"
> VerticalAlignment="{TemplateBinding
> Control.VerticalContentAlignment}">
> <TextBlock.Text>
> <Binding Source="{TemplateBinding Header}" />
> </TextBlock.Text>
> </TextBlock>
> </DataTemplate>
> </Setter.Value>
> </Setter>
> <Setter Property="Template">
> <Setter.Value>
> <ControlTemplate TargetType="{x:Type
> src:ConditionBuilderItem}">
> <Border Background="{TemplateBinding Background}"
> BorderBrush="{TemplateBinding BorderBrush}"
> BorderThickness="{TemplateBinding
> BorderThickness}"
> SnapsToDevicePixels="{TemplateBinding
> SnapsToDevicePixels}">
> <ContentPresenter
> Margin="{TemplateBinding Padding}"
> Content="{TemplateBinding Header}"
> ContentTemplate="{TemplateBinding
> HeaderTemplate}"
> ContentSource="Header"
> HorizontalAlignment="{TemplateBinding
> HorizontalContentAlignment}" />
> </Border>
> </ControlTemplate>
> </Setter.Value>
> </Setter>
> </Style>
>
> But this does not work. From the HeaderTemplate, I cannot access
> MyControl, since TemplateBinding is working with ContentProsenter.
> Morever, I have a bad feeling of this piece of XAML, I don't think it
> should be done this way, should it? Is there any reference available for
> creating Headered custom controls?
>
> Thank you,
> Jan
>
>



My System SpecsSystem Spec