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

Binding Issues with MEF IsHidden property in RadPane

6 Answers 47 Views
Docking
This is a migrated thread and some comments may be shown as answers.
mirang
Top achievements
Rank 1
mirang asked on 21 Sep 2011, 12:40 PM
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 ?

6 Answers, 1 is accepted

Sort by
0
mirang
Top achievements
Rank 1
answered on 21 Sep 2011, 01:32 PM
This issue is not only with MEF, it is also the case with the pasted code....
0
Konstantina
Telerik team
answered on 23 Sep 2011, 01:45 PM
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 >>
0
mirang
Top achievements
Rank 1
answered on 23 Sep 2011, 02:52 PM
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.
0
Konstantina
Telerik team
answered on 28 Sep 2011, 11:49 AM
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 >>
0
mirang
Top achievements
Rank 1
answered on 28 Sep 2011, 11:53 AM
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.
0
Konstantina
Telerik team
answered on 29 Sep 2011, 01:49 PM
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 >>
Tags
Docking
Asked by
mirang
Top achievements
Rank 1
Answers by
mirang
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or