When I set RadPane.IsHidden to 'false' after it has been set to 'true' the RadPain remains invisible.

4 posts, 1 answers
  1. Yaroslav
    Yaroslav avatar
    123 posts
    Member since:
    Jan 2016

    Posted 15 Aug Link to this post

    Hello. When I set RadPane.IsHidden to 'false' after it has been set to 'true' the RadPain remains invisible. Below is XAML markup:
    <UserControl x:Class="DeviceReading.Views.DeviceReadingView"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:prism="http://prismlibrary.com/"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 prism:ViewModelLocator.AutoWireViewModel="True">
     
    . . . . . . . . . . . . . . . . . . .
    <StackPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" Margin="0 5 0 3" Orientation="Horizontal">
       <CheckBox Content="Gas Velocity" Command="{Binding Path=ShowHideGasVelocityChartViewCommand}" CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource Self}}"/>
    </StackPanel>
    <telerik:RadDocking Grid.Row="1" Grid.Column="0" x:Name="Docking">
    . . . . . . . . . . . . . . . . . . .
       <telerik:RadSplitContainer>
          <telerik:RadPaneGroup>
             <telerik:RadPane Header="Gas Velocity" IsHidden="{Binding IsGasVelocityChartHidden, Mode=TwoWay}" prism:RegionManager.RegionName="GasVelocityChartRegion" />
          </telerik:RadPaneGroup>
       </telerik:RadSplitContainer>
    . . . . . . . . . . . . . . . . . . .
    </telerik:RadDocking>
    . . . . . . . . . . . . . . . . . . .
     
    </UserControl>

    Where UserControl is Prism UserControl. Below is ViewModel code.

    public class DeviceReadingViewModel : BindableBase, IConfirmNavigationRequest
    {
       . . . . . . . . . .
       public DeviceReadingViewModel(IEventAggregator eventAggregator)
       {
         this._eventAggregator = eventAggregator;
         this.ShowHideGasVelocityChartViewCommand = new DelegateCommand<object>(this.showHideGasVelocityChartView);
       }
     
       // Field and property controlling of the RadPain status (Visible / Hidden)
       private bool _isGasVelocityChartHidden;
       public bool IsGasVelocityChartHidden
       {
          get { return this._isGasVelocityChartHidden; }
          set { this.SetProperty(ref this._isGasVelocityChartHidden, value); }
       }
     
       // The command of hidding / visualizing of the RadPain.
       public DelegateCommand<object> ShowHideGasVelocityChartViewCommand { get; private set; }
     
       private void showHideGasVelocityChartView(object parameter)
       {
          if ((bool)parameter == true)
            this.IsGasVelocityChartHidden = false;
          else
            this.IsGasVelocityChartHidden = true;
       }
    }

    Initially (after application loading) the RadPain is visible and the CheckBox is unchecked. When I check the CheckBox first then the RadPain become invisible. But when I uncheck the CheckBox after it then the RadPain remains invisible (but the command is fired). How to have the command display the RadPain each time the CheckBox is unchecked? What I'm doing wrong?
  2. Yaroslav
    Yaroslav avatar
    123 posts
    Member since:
    Jan 2016

    Posted 15 Aug in reply to Yaroslav Link to this post

    I bag your pardon. In command method I have:

    private void showHideGasVelocityChartView(object parameter)
    {
       if ((bool)parameter == true)
         this.IsGasVelocityChartHidden = true;
       else
         this.IsGasVelocityChartHidden = false;
    }

    But the problem remains. The RadPain is not visualized after the CheckBox has been unchecked. Please help.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 15 Aug Link to this post

    Hi Yaroslav,

    When the IsHidden gets set to True the Panes that are bound gets removed from the visual tree. Because of that when the IsHidden is set to False the binding no longer is working as expected and the Panes could not be visualized. In order the bindings to be preserved and everything to work as expected the DataContext of the Panes should be set with the DataContext of its parent as shown below:
    <telerik:RadPane DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadDocking}}, Path=DataContext}"  Header="ViewB"
    regions:RegionManager.RegionName="ModuleB" IsHidden="{Binding IsHidden, Mode=TwoWay}"/>

    Please, give it a try.

    Hope this helps.

    Regards,
    Nasko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  5. Yaroslav
    Yaroslav avatar
    123 posts
    Member since:
    Jan 2016

    Posted 15 Aug in reply to Nasko Link to this post

    Hello, Nasco. Thank you very much for your help. Now 'RadPain.IsHidden' property works as I need. Thank you.
Back to Top