Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Display custom header from UserControl
posted

I'm using the composite guidance for Silverlight. I'm trying to use the XamWebOutlookBar as a region and stick views in it through injection.

I can inject the views just fine but my remaining issue is to display a custom header in the group headers. I can do that just fine using POCO but with views it doesn't seem to work.

The group style I use is:

        <Style x:Key="GroupStyle" TargetType="igOB:OutlookBarGroup">
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                            <TextBlock Text="{Binding Path=HeaderInfo}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

and the view has a HeaderInfo property in its DataContext but it doesn't show anything. Am I missing something? Using TabControl and TabItem, the above code was working.

Parents
No Data
Reply
  • 19693
    Suggested Answer
    posted

    Hello ,

    You should add also DataContext . Below is the code snippet.

    Book is a simple class which has the property Author.

      <UserControl

       xmlns:igOB="clr-namespace:Infragistics.Silverlight.Controls;assembly=Infragistics.Silverlight.XamWebOutlookBar.v9.1"   x:Class="CustomHeader.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CustomHeader">
        <UserControl.Resources>
            <local:Book
                x:Key="MyView"
                Author="Custom HeaderInfo"/>

            <Style x:Key="GroupStyle"
                   TargetType="igOB:OutlookBarGroup">
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock
                                Text="{Binding Author}"
                                DataContext="{StaticResource MyView}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </UserControl.Resources>

        <Grid  x:Name="LayoutRoot" Background="White" >

            <igOB:XamWebOutlookBar
                x:Name="XamWebOutlookBar"
                Width="250"
                MinimizedWidth="38" >

                <igOB:OutlookBarGroup  
                    Style="{StaticResource GroupStyle}"
                    Key="dailyActivitiesGroup" >
                    <StackPanel>
                        <Button Content="Tasks" />
                        <Button Content="Notes"/>
                    </StackPanel>
                </igOB:OutlookBarGroup>

            </igOB:XamWebOutlookBar>

        </Grid>
    </UserControl>

     

Children
No Data