Binding Issues with MEF IsHidden property in RadPane

7 posts, 0 answers
  1. mirang
    mirang avatar
    115 posts
    Member since:
    Aug 2010

    Posted 21 Sep 2011 Link to this post

    PFA a sample  which will illustrate the problem. 
    I am seeing a very strange behavior while setting the ishidden property through code. Run the pasted code as it is, you will see the problem.
    This problem arrises when the IsHidden property is initially set to true.

    MainPage.xaml

    <UserControl x:Class="RadDockingIsHidden.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:telerikdocking="http://schemas.telerik.com/2008/xaml/presentation" 
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">


        <Grid x:Name="LayoutRoot" Background="White">
            <telerikdocking:RadDocking x:Name="rootDocking" AllowUnsafeMode="True" 
                                       Padding="0" Margin="0" BorderThickness="0 1 0 0"
                                       HasDocumentHost="False">
                <telerikdocking:RadSplitContainer 
                                           x:Name="splitContainer1"
                                           InitialPosition="DockedRight" 
                                           Orientation="Horizontal">
                    <telerikdocking:RadPaneGroup >
                        <telerikdocking:RadPane x:Name="paneLeft" Header="Left"
                                                ContextMenuTemplate="{x:Null}"
                                                Padding="0" CanUserClose="False" CanFloat="False" CanUserPin="False">
                            <Button Content="Left" Click="Button_Click" />
                        </telerikdocking:RadPane>
                    </telerikdocking:RadPaneGroup>
                    <telerikdocking:RadPaneGroup x:Name="previewPaneGroup"
                                                 >
                        <telerikdocking:RadPane x:Name="rightPane" Foreground="White"
                                                IsHidden="{Binding IsRightHidden, Mode=TwoWay}" 
                                                Header="Preview"
                                                CanUserClose="True" CanFloat="False" CanUserPin="False"
                                                ContextMenuTemplate="{x:Null}"
                                                >
                            <Button Content="Right" />
                        </telerikdocking:RadPane>
                    </telerikdocking:RadPaneGroup>
                </telerikdocking:RadSplitContainer>
            </telerikdocking:RadDocking>
        </Grid>
    </UserControl>


    MainPage.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.ComponentModel;


    namespace RadDockingIsHidden
    {
        public partial class MainPage : UserControl, INotifyPropertyChanged
        {
            public MainPage()
            {
                Loaded += new RoutedEventHandler(ResultsPane_Loaded);
            }


            //RightViewModel vm = new RightViewModel();
            void ResultsPane_Loaded(object sender, RoutedEventArgs e)
            {
                InitializeComponent();
                DataContext = this;
                IsRightHidden = true;
            }


            private bool isRightHidden;
            public bool IsRightHidden
            {
                get
                {
                    return isRightHidden;
                }
                set
                {
                    isRightHidden = value;
                    RaisePropertyChanged("IsRightHidden");
                }
            }
            public void RaisePropertyChanged(string propName)
            {
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                IsRightHidden = !IsRightHidden;
            }


            public event PropertyChangedEventHandler PropertyChanged;
        }
    }
    ----- Steps to get the issue
    1. Run the code
    2. Click the left button to open the right pane.
    3. Again click the left button to close the right pane
    4. Again click the left button to open the right pane..
    5. You see that the entire binding of the right pane is lost.

    Is this a known issue ?
  2. mirang
    mirang avatar
    115 posts
    Member since:
    Aug 2010

    Posted 21 Sep 2011 Link to this post

    This issue is not only with MEF, it is also the case with the pasted code....
  3. DevCraft banner
  4. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 23 Sep 2011 Link to this post

    Hi Mirang,

    I am sending you a sample project in which is illustrated how to bind to the IsHidden property of the RadPane.

    Hope this helps.

    Best wishes,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  5. mirang
    mirang avatar
    115 posts
    Member since:
    Aug 2010

    Posted 23 Sep 2011 Link to this post

    Actually, when i set the ishidden property on loaded event of previewPaneGroup, instead of loaded event of the usercontrol, as in the below example, everything worked fine. Let me know if this behavior is expected.
  6. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 28 Sep 2011 Link to this post

    Hello Mirang,

    Sorry, but I wasn't able to understand what you are asking. Could you please explain what difficulties do you experience?

    All the best,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  7. mirang
    mirang avatar
    115 posts
    Member since:
    Aug 2010

    Posted 28 Sep 2011 Link to this post

    when you use the above pasted code you will see that the ishidden doesnt work properly when the property is set in the loaded event of the usercontrol. But when the ishidden is set in the panegroup loaded event it works.
  8. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 29 Sep 2011 Link to this post

    Hi Mirang,

    Initially, a recommended approach is this property to be bound through a ViewModel, then non of these problems will exist. Also, setting the DataContext to this, i.e to the pane is not recommended.

    Hope this information is useful.

    All the best,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
DevCraft banner