This is a migrated thread and some comments may be shown as answers.

RadPane header showing a different content based on the dock location

1 Answer 22 Views
Docking
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 2
B asked on 26 Mar 2015, 11:38 AM
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

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 30 Mar 2015, 11:32 AM
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.

 
Tags
Docking
Asked by
B
Top achievements
Rank 2
Answers by
Nasko
Telerik team
Share this question
or