![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| Guest | Headered custom control 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 Specs![]() |
| | #2 (permalink) |
| Guest | 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 Specs![]() |
| | #3 (permalink) |
| Guest | Re: Headered custom control Hi Lloyd, thank you for the tip with BAML reader. The problem is that none of the built-in headered controls has a template for header. But I will probably go the same way... In the code I posted, btw, seems to be error in using TemplateBinding inside DataTemplate. Jan "Lloyd Dupont" <net.galador@ld> wrote in message news:#eB0z#mxHHA.484@TK2MSFTNGP06.phx.gbl... >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 Specs![]() |
| Thread Tools | |
| |