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

How can I enable / disable RadPanelBar item so that we cannon navigate to it.

3 Answers 138 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Maciej
Top achievements
Rank 1
Maciej asked on 21 Nov 2016, 05:02 PM

Hi,

I have code written by fellow developer who used RadPanelBar to visualize hierarchical datasouce. He wrote (imho too many) templates. Now I am looking how to enable / disable item - I would say functionality like this in TreeViewItem
http://docs.telerik.com/devtools/wpf/controls/radtreeview/features/treeview-item/feautres-treeviewitem-enable-disable-items
I managed to block action in code, nonetheless I am looking how to set it so that it looks nice visually (and I wish to avoid to write xaml code in order just to disable item;))

Best regards,

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 Nov 2016, 12:11 PM
Hello Maciej,

Using a custom style you can bind the RadPanelBar IsEnabled property to a property from your model. This way you can control which panel bar item to be enabled or not.
<Style TargetType="telerik:RadPanelBarItem">
    <Setter Property="IsEnabled" Value="{Binding IsEnabledProperty}"/>
</Style>

As for your other question, you can use two options using a Triggers or edit the default Template of the control which depends on the theme wich you are using so you can change the appearance of the disabled items. 

I'll explain why below. Our latest themes -- Green and Office2016 are supported in WPF only and thus the changing of visual appearance is made with Triggers primarily (supported in WPF only).  So for these themes using a Trigger that changes the Background (for example) color on an IsEnabled property is absolutely correct approach and should work without problems.

On the other side, our older themes (before Green) are supported in both SL and WPF platforms. This is the reason why we've been using the Visual States instead of Triggers for them. Please mind that even though combining both VisualStates and Triggers in a Control Template is absolutely possible this might confuse you in this case and might lead to unexpected results. For example, when you are triggering IsEnabled = False this is practically equal to executing a Disabled Visual State. You are trying to change the Background (for example) of the RadPabelBarItem but the Disabled VisualState (that is already present in the theme style you are using) adds additional Border visual on top and changes its Background.
You have two options to choose from in such case:
1. You might either modify the ControlTemplate of the RadPanelBarItem that we ship with the current theme and comment or delete the Disabled VisualState so that it don't interfere with your Trigger. You can take a look at the Editing Control Templates help article in our documentation.
2. Directly modify the Disabled VisualState in the ControlTemplate and don't mix triggers with visual states that are executing the same action.

Regards,
Dinko
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
0
Maciej
Top achievements
Rank 1
answered on 08 Dec 2016, 12:57 PM
Hi Dinko,

Thank you for you answer. In fact I was a little bit wrong with this what I want to do:) I described it improperly.
I have HierarchicalDataTemplate and DataTemplate like in example:
http://docs.telerik.com/devtools/wpf/controls/radpanelbar/howto/display-hierarchical-data
What I really wanted to do is to disable DataTemplate item so that it looks like disabled and it's not possible to select it. In our case the control is a menu control. Is it possible?

Have a nice day,
Best regards,
Maciek
0
Dinko | Tech Support Engineer
Telerik team
answered on 12 Dec 2016, 03:48 PM
Hello Maciej,

Thank you for clarifying your approach but we are still not exactly sure what you are trying to achieve in your application. Basically, you can disable the panel bar item by binding the IsEnabled property to a property from your view model. We have created sample project based on the article which you mentioned in your last reply.  Can you give this project a try and let us know if this works for you. If not can you elaborate more on what you want to disable? The panel bar item itself, or the style of the RadPanelBarItem but not the content of the item. In the attached project only the third child is enabled.

Regards,
Dinko
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
PanelBar
Asked by
Maciej
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Maciej
Top achievements
Rank 1
Share this question
or