I wan to put something in SelectedGroudHeader, so create a style as blow. I add ContentContainer "MyControl" to the header in template style. Then I want to set different content for different OutlookBarGroup. For exaplme, different OutlookBarGroup with different menu inside MyControl.
Asthis style is applied to all OutlookBarGroup, how can I do it in xaml or in code-behind in this case?
<Style x:Key="SelectedHeaderStyle" TargetType="igPrim:SelectedGroupHeader"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStopCollection> <GradientStop Offset="0" Color="#FFba53be"/> <GradientStop Offset="0.972" Color="#FF751a71"/> </GradientStopCollection> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="#034A53BE"/> <Setter Property="Foreground" Value="#FFFFFFFF"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igPrim:SelectedGroupHeader"> <Grid Margin="0,0,0,1"> <Border Background="{TemplateBinding Background}" BorderThickness="0"> <Grid> <Grid.Resources> <igPrim:GroupHeaderConverter x:Key="HeaderConverter"/> <igPrim:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <ContentPresenter x:Name="ContentPresenterHeader" Grid.Column="0" Margin="7,7,8,3" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.SelectedGroup.Header, Converter={StaticResource HeaderConverter}}" ContentTemplate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.SelectedGroup.HeaderTemplate}" Visibility="Visible"/> <ContentControl x:Name="MyControl"></ContentControl> <ToggleButton x:Name="MinimizeButton" Grid.Column="2" Margin="0,4,0,3" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.IsMinimized, Mode=TwoWay}" RenderTransformOrigin="0.5 0.5" Style="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.MinimizeToggleButtonStyle}" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.AllowMinimized, Converter={StaticResource BoolToVisibilityConverter}}"> <ToolTipService.ToolTip> <Grid> <TextBlock x:Name="ExpandTooltip" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.StringSettings.MinimizeButtonExpandTooltip}" Visibility="Collapsed"/> <TextBlock x:Name="MinimizeTooltip" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OutlookBar.StringSettings.MinimizeButtonMinimizeTooltip}"/> </Grid> </ToolTipService.ToolTip> <ToggleButton.RenderTransform> <RotateTransform x:Name="TgbRotation" Angle="0"/> </ToggleButton.RenderTransform> </ToggleButton> </Grid> </Border> <Border x:Name="innerBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,0,0"/> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="MinimizedStates"> <VisualState x:Name="Expanded"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="ContentPresenterHeader" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Visible"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Minimized"> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="ContentPresenterHeader" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Collapsed"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="MinimizeButton" Storyboard.TargetProperty="ToggleButton.RenderTransform.RotateTransform.Angle"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="180"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="MinimizeTooltip" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Collapsed"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="ExpandTooltip" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Visible"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
Hello,
I have created a sample which I believe demonstrates a method to resolve your issue. In the sample I have added a StackPanel around the existing Content Presenter, ContentPresenterHeader, which is used to display either the header text or header template for the selected group. In doing this you can add content to the “selected group header” by adding controls either before or after the content presenter in the StackPanel. In this example I am adding a menu after the normal header presented. In order to show a specific menu based on the group selected, I have added a converter which is being used to set the visibility on the menu.
Let me know if you have any questions or if you were looking for something different.
Valerie
Were you able to resolve your issue?