IsHidden Problem in RadPane with binding

6 posts, 0 answers
  1. Ravi
    Ravi avatar
    97 posts
    Member since:
    Jun 2012

    Posted 16 Apr 2013 Link to this post

    Hi There,

    I have a problem with RadPanes isHidden property, i want to set IsHidden by using a binding, but when i do this it is not working, but if i set the IsHidden="True" at XAML then its working properly, can you please guide me in this case ?

    Thanks in advance,
    Srinivas.
  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 18 Apr 2013 Link to this post

    Hi Srinivas,

    When a RadPane is hidden it is moved out of the visual tree so its DataContext is set to null. When the DataContext is set to null the IsHidden binding is lost and you cannot show it again. However if you explicitly set the DataContext of the RadPane it will not be lost and everything will work as expected. here is sample code:

    XAML
    <Window.Resources>
        <local:ViewModel x:Key="ViewModel" />
    </Window.Resources>
     
    <Grid DataContext="{Binding Source={StaticResource ViewModel}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="22" />
            <RowDefinition />
        </Grid.RowDefinitions>
         
        <CheckBox Content="Is Hidden" IsChecked="{Binding IsHidden, Mode=TwoWay}" />
         
        <telerik:RadDocking Grid.Row="1">
            <telerik:RadSplitContainer>
                <telerik:RadPaneGroup>
                    <telerik:RadPane Header="Pane 1" DataContext="{StaticResource ViewModel}" IsHidden="{Binding IsHidden, Mode=TwoWay}" />
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking>
    </Grid>

    Greetings,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 18 Oct 2013 Link to this post

    Well this answers why I am unable to locate my pane using the following method when the IsHidden property is set.

    CustomerOrderDetailsPane customerOrderDetailsPane = this.FindChildByType<CustomerOrderDetailsPane>();


    Can you recommend a way to hide a pane but still allow it to be searchable?

    Would collapsing the visibility setting work better?

    Many thanks,

    Rob
  5. George
    Admin
    George avatar
    1332 posts

    Posted 22 Oct 2013 Link to this post

    Hello Rob,

    You could set the x:Name of the Pane and use it in the code-behind as well. Hope this helps.


    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. John
    John avatar
    17 posts
    Member since:
    Aug 2014

    Posted 26 Oct in reply to Ivo Link to this post

    Only direct binding works? Because the setter in the style(<Setter Property="IsHidden" Value="True" />) is not being applied:
    <t:RadPane HorizontalAlignment="Left" CanUserClose="False" Title="Gates" DataContext="{Binding Active, Source={gui:SubApplicationSelectorRetreiver}}"
               DataContextChanged="RadPane_DataContextChanged">
        <t:RadPane.Style>
            <Style TargetType="t:RadPane" BasedOn="{StaticResource MyPaneStyle}">
                <Setter Property="IsHidden" Value="True" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Converter={StaticResource typeof}}" Value="{x:Type local:MDVDesignerAdapter}">
                        <Setter Property="IsHidden" Value="False" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </t:RadPane.Style>
        <t:RadPane.ContentTemplate>
            <DataTemplate>
                <local:MDVToolbox />
            </DataTemplate>
        </t:RadPane.ContentTemplate>
    </t:RadPane>
  7. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 28 Oct Link to this post

    Hello John,

    The observed by you behavior is an expected one when DataTriggers are used. When the Pane is visualized (IsHidden is True) the property takes precedence over the the DataTrigger - you could no longer change its value through the Trigger.

    We suggest you to consider using direct binding for the IsHidden property instead of using Triggers to change its value.

    Hope the provided information will be helpful for you.

    Regards,
    Nasko
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Back to Top
UI for WPF is Visual Studio 2017 Ready