RadPane header showing a different content based on the dock location

2 posts, 0 answers
  1. B
    B avatar
    74 posts
    Member since:
    Jul 2011

    Posted 26 Mar 2015 Link to this post


    I would like to show a different header for the RadPane based on where it is docked, I came up with this:

    <conv:NullToVisibilityConverter x:Key="NullToVisibilityConverterInverse"
                                    Inverse="True" />
    <conv:NotVisibilityConverter x:Key="NotVisibilityConverter" />
    <DataTemplate x:Key="CockpitPaneHeaderTemplate">
            <Image Source="/PowerBrowser;component/Modules/Images/OutlookBar/Cockpit.png"
                   Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:DocumentHost},
                        Converter={StaticResource NullToVisibilityConverterInverse}}" />
            <TextBlock Text="{Binding}"
                       Visibility="{Binding ElementName=CockputImage, Path=Visibility, Converter={StaticResource NotVisibilityConverter}}"/>

    So based on if FindAncestor finds a DocumentHost (or crashes) it will set the visibility.

    Although it works, it is a bit hacked and fragile. The reason it works (I think) is that FindAncestor will fail when DocumentHost is not found and the internal error recovery of Silverlight will ignore the error and keep the default Visibility which is Visible and if the pane is invisible I don't care if it works or not because it wont be visible anyway. So all in all it sort of works, but not in a nice way.

    Is there a better way to do this?


  2. Nasko
    Nasko avatar
    727 posts

    Posted 30 Mar 2015 Link to this post

    Hello Demir,

    We could not guarantee that the approach that we you came up with will work as expected in all scenarios. However, what we could suggest you is instead using DocumentHost to use RadPane in order to determine the Visibility of the Image. RadPane provides lots of properties that you could use to found the current position of the Pane. Thus you will avoid the scenario where DocumentHost is missing.

    Hopes this helps.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top