ishidden binding

10 posts, 0 answers
  1. Aurore
    Aurore avatar
    58 posts
    Member since:
    Nov 2007

    Posted 07 Jun 2010 Link to this post

    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



  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 09 Jun 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. David
    David avatar
    3 posts
    Member since:
    Jul 2010

    Posted 24 Aug 2010 Link to this post

    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
  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 30 Aug 2010 Link to this post

    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
  6. David
    David avatar
    3 posts
    Member since:
    Jul 2010

    Posted 30 Aug 2010 Link to this post

    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
  7. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 02 Sep 2010 Link to this post

    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
  8. David
    David avatar
    3 posts
    Member since:
    Jul 2010

    Posted 02 Sep 2010 Link to this post

    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
  9. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 06 Sep 2010 Link to this post

    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
  10. Rayne
    Rayne avatar
    241 posts
    Member since:
    Sep 2010

    Posted 10 Nov 2010 Link to this post

    Thank you. This is exactly what I was looking for.

    - Rayne
  11. M
    M avatar
    5 posts
    Member since:
    Mar 2012

    Posted 31 Jan 2013 Link to this post

    Thank you, this explains ans solved my problem
Back to Top
UI for WPF is Visual Studio 2017 Ready