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

    Hi,

    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">
        <Grid>
            <Image Source="/PowerBrowser;component/Modules/Images/OutlookBar/Cockpit.png"
                   Width="16"
                   Height="16"
                   x:Name="CockputImage"
                   Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:DocumentHost},
                        Converter={StaticResource NullToVisibilityConverterInverse}}" />
            <TextBlock Text="{Binding}"
                       Visibility="{Binding ElementName=CockputImage, Path=Visibility, Converter={StaticResource NotVisibilityConverter}}"/>
        </Grid>
    </DataTemplate>

    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?

    Regards,

    Bayram
  2. Nasko
    Admin
    Nasko avatar
    586 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.

    Regards,
    Nasko
    Telerik
     

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

     
  3. DevCraft banner
Back to Top