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
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.
Thanks,
Dave
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,
the Telerik team
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
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
Thanks
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.
Miroslav Nedyalkov
the Telerik team
- Rayne