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

ishidden binding

9 Answers 194 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Aurore
Top achievements
Rank 1
Aurore asked on 07 Jun 2010, 03:10 PM
Hello,

I'd like to show/hide a radpane following a user choice, store in my code.

When user clicks on menu "hide/show zoom"
  I set the ishidden property by program and it works.

Now, I'd like that my code boolean will be update when user close directly the radpane (x).

I use this code :
 
<telerik:RadSplitContainer InitialPosition="FloatingOnly"
                    telerik:RadDocking.FloatingLocation="250, 50" MinWidth="150" MinHeight="150">
                <telerik:RadPaneGroup >
<
telerik:RadPane CanDockInDocumentHost="False" CanUserClose="True" x:Name="paneZoom" 
                                     Header="Zoom" IsHidden="{Binding DisplayZoom, Mode=TwoWay}"

but, my DisplayZoom property is not setting.

Have you an idea ?
Aurore



9 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 09 Jun 2010, 11:59 AM
Hello Aurore,

 I tried to reproduce your scenario and the only problem I was able to reproduce was that when the pane is hidden the binding fails to update. On the other hand this is expected, because the Pane is removed from the visual tree, so it doesn't inherit the value of the DataContext property anymore. You could work-this-around using ElementName property of the Binding. You could refer to the following example:

<Grid x:Name="root">
    <CheckBox VerticalAlignment="Top" Height="50" Width="50" x:Name="paneIsHiddenCheckBox" />
    <CheckBox VerticalAlignment="Top" Height="50" Width="50" Margin="50 0 0 0" IsChecked="{Binding IsPaneHidden, Mode=TwoWay}" />
    <telerik:RadDocking Margin="0 50 0 0">
        <telerik:RadSplitContainer>
            <telerik:RadPaneGroup>
                <telerik:RadPane Header="pane(bound directly to checkbox)"
                        IsHidden="{Binding IsChecked, ElementName=paneIsHiddenCheckBox, Mode=TwoWay}" />
                <telerik:RadPane Header="pane(bound to view-model)"
                                 DataContext="{Binding DataContext, ElementName=root}"
                        IsHidden="{Binding IsPaneHidden, Mode=TwoWay}" />
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
    </telerik:RadDocking>
</Grid>

The DataContext of the Grid is the ViewModel that has a IsPaneHidden property and implements INotifyPropertyChanged.

Hope this helps!

All the best,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David
Top achievements
Rank 1
answered on 24 Aug 2010, 04:49 PM
Why can I bind to a element on the view but not to a property of a view model that is set as the data context of the page?  My work around seems like a hack to me.  I have a Checkbox control that has a visibility "Collapsed" that is bound to my view model and my RadPane to the "Collapsed" Checkbox.  This works but like I said it seems like a hack.

Thanks,
Dave
0
Miroslav Nedyalkov
Telerik team
answered on 30 Aug 2010, 02:58 PM
Hello David,

 As I explained in my previous post, the DataContext is inherited trough the visual tree, and when you set your ViewModel to be a DataContext of the Docking control for example, the elements that are not in the visual tree will not inherit it. This is how WPF works.
Kind regards,

Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 30 Aug 2010, 03:06 PM
How is the "IsHidden" property implemented in the RadPane control?  If I set the visibility property on a control to "Collapsed" it is still part of the visual tree and can be bound to the Data Context.   What is keeping the RadPane int he visual tree when it is bound to another control as opposed to the Data Context? 

My solution feels like such a hack but it seems to be the only way to implement I want using MVVM.  It is making me question whether I should even use the RadPane control.

Thanks
0
Miroslav Nedyalkov
Telerik team
answered on 02 Sep 2010, 08:08 AM
Hi David,

 When the IsHidden property is set to True the pane is removed from the Items collection of the PaneGroup. This is the reason why it is removed from the VisualTree.

Kind regards,
Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 02 Sep 2010, 01:33 PM
Is there a reason that is removed from the PaneGroup as opposed to setting it visibility property?  I think that this would lend itself to patterns like MVVM a little better.  Just a thought

Thanks
0
Miroslav Nedyalkov
Telerik team
answered on 06 Sep 2010, 01:49 PM
Hello David,

 Thank you for sharing your opinion! We will consider your arguments.
The reason why we remove the pane from the Items collection instead of just changing its Visibility is because removing it from the Items collection guarantees us that this pane will not be selectable anymore.

Best wishes,
Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rayne
Top achievements
Rank 1
answered on 10 Nov 2010, 06:34 PM
Thank you. This is exactly what I was looking for.

- Rayne
0
M
Top achievements
Rank 1
answered on 31 Jan 2013, 08:49 AM
Thank you, this explains ans solved my problem
Tags
Docking
Asked by
Aurore
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
David
Top achievements
Rank 1
Rayne
Top achievements
Rank 1
M
Top achievements
Rank 1
Share this question
or