We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Enable/Disable items in SfTreeNavigator

Does anyone know how to enable/disable menu items in SfTreeNavigator

14 Replies

DV Duraimurugan Vedagiri Syncfusion Team April 6, 2020 04:38 PM UTC

Hi Mariusz,

Thanks for using syncfusion products.

Currently, we are trying to achieve your reported requirement and will update you the further details on April 8th, 2020.

Regards,
Durai



DV Duraimurugan Vedagiri Syncfusion Team April 7, 2020 03:01 PM UTC

Hi Mariusz,

Thanks for your patience.

You can achieve your requirement by using TreeMenuItem.Enabled bool property. Please refer the below code snippet and sample for your reference.

public Form1() 
{ 
    InitializeComponent(); 
    //Adds items to the TreeNavigator. 
    treeNavigator.Header.HeaderText = "This PC"; 
    TreeMenuItem treemenuitem1 = new TreeMenuItem(); 
    treeNavigator.Items.Add(treemenuitem1); 
    treemenuitem1.Text = "Desktop"; 
    TreeMenuItem treemenuitem2 = new TreeMenuItem(); 
    treeNavigator.Items.Add(treemenuitem2); 
    treemenuitem2.Text = "Document"; 
    TreeMenuItem treemenuitem3 = new TreeMenuItem(); 
    treeNavigator.Items.Add(treemenuitem3); 
    treemenuitem3.Enabled = false; 
    treemenuitem3.ItemBackColor = Color.LightGray; 
    treemenuitem3.Text = "Downloads"; 
} 



MJ Mariusz Juszkiewicz April 8, 2020 12:42 AM UTC

Thanks Durai.
I am having problem opening the example link. It tell me I do not have Access.
What namespace is TreeMenuItem under? Cannot find the class.


DV Duraimurugan Vedagiri Syncfusion Team April 8, 2020 05:07 AM UTC

Hi Mariusz,

Sorry for the inconvenienced cause.

Please refer the sample from the following link :

https://www.syncfusion.com/downloads/support/forum/153051/ze/SampleTreeNavigator-2035544166.zip  

Query : What namespace is TreeMenuItem under?

You, can achieve by using following namespace "using Syncfusion.Windows.Forms.Tools;".

Regards,
Durai


MJ Mariusz Juszkiewicz April 9, 2020 12:32 AM UTC

Sorry but I am still unable to open the example.

is Syncfusion.Windows.Forms.Tools winforms or WPF?


DV Duraimurugan Vedagiri Syncfusion Team April 9, 2020 05:06 AM UTC

Hi Mariusz,

We deeply regret for the inconvenience caused.

Can achieve your requirement “How to Enable/disable menu items in SfTreeNavigator
by using IsEnable bool property. Please refer the below code snippet and sample for your reference.

Code Snippet
<Grid> 
    <navigation:SfTreeNavigator Header="Enterprise Toolkit" Margin="0,0,540,0"> 
        <navigation:SfTreeNavigatorItem Header="WinRT (XAML)" > 
            <navigation:SfTreeNavigatorItem Header="Chart"/> 
            <navigation:SfTreeNavigatorItem Header="Tools"/> 
        </navigation:SfTreeNavigatorItem> 
        <navigation:SfTreeNavigatorItem Header="Metro Studio" IsEnabled="False"/> 
    </navigation:SfTreeNavigator> 
</Grid> 

Sample : https://www.syncfusion.com/downloads/support/forum/153051/ze/TreeNavigatorExample1477148263.zip 

Regards,
Durai


MJ Mariusz Juszkiewicz April 20, 2020 03:40 AM UTC

Thank you for your response. This work if I define the items in XAML. My items get loaded from ViewModel class
public class TreeViewModel
    {
       
        private List<TreeModel> models;
        public List<TreeModel> Models
        {
            get { return models; }
            set { models = value; }
        }
        public TreeViewModel()
        {
            Models = new List<TreeModel>();
            TreeModel Admin = new TreeModel() { Header = "Administration" };
            TreeModel Proposals = new TreeModel() { Header = "Proposals" };
            TreeModel Estimates = new TreeModel() { Header = "Estimates" };
            TreeModel Estimators = new TreeModel() { Header = "Estimators" };
            TreeModel LabRate = new TreeModel() { Header = "Labour Rate Collection" };
            TreeModel ShiftCal = new TreeModel() { Header = "Shift Calendar Collection" };
            TreeModel CrewMix = new TreeModel() { Header = "Crew mix Collection" };
            TreeModel EstCode = new TreeModel() { Header = "Estimate Coding" };
            TreeModel Lookup = new TreeModel() { Header = "Lookup Lists" };
            TreeModel Owner = new TreeModel() { Header = "Customer/Owner List" };
            TreeModel Eng = new TreeModel() { Header = "Engineer List" };
            TreeModel Comp = new TreeModel() { Header = "Company/Division List" };
            TreeModel Propstat = new TreeModel() { Header = "Proposal Status List" };
            TreeModel PropGroup = new TreeModel() { Header = "Proposal Group List" };
            TreeModel EstType = new TreeModel() { Header = "Estimate Type List" };

            Lookup.Models.Add(Owner);
            Lookup.Models.Add(Eng);
            Lookup.Models.Add(Comp);
            Lookup.Models.Add(Propstat);
            Lookup.Models.Add(PropGroup);
            Lookup.Models.Add(EstType);

            Admin.Models.Add(Estimators);
            Admin.Models.Add(LabRate);
            Admin.Models.Add(ShiftCal);
            Admin.Models.Add(CrewMix);
            Admin.Models.Add(EstCode);
            Admin.Models.Add(Lookup);
           

            Models.Add(Proposals);
            Models.Add(Estimates);
            Models.Add(Admin);
        }
        private object selecteditem;
        public object SelectedItem
        {
            get { return selecteditem; }
            set { selecteditem = value; }
        }


DV Duraimurugan Vedagiri Syncfusion Team April 21, 2020 12:19 PM UTC

Hi Mariusz,

Thanks for your update.

You can achieve your requirement “How to Enable/disable menu items in SfTreeNavigator using MVVM” to customize the SfTreeNavigator.ItemContainerStyle by binding the IsEnable property for SfTreeNavigatorItem.

Please refer the below code snippet and sample for your reference.

Code Snippet
<Grid> 
    <navigation:SfTreeNavigator ItemsSource="{Binding Models}"   
                            Header="Enterprise Toolkit" 
                            Width="300" Height="400" 
                            HorizontalAlignment="Center" 
                            VerticalAlignment="Center" > 
        <navigation:SfTreeNavigator.ItemTemplate> 
            <HierarchicalDataTemplate ItemsSource="{Binding Models}"> 
                <StackPanel Orientation="Horizontal"> 
                    <TextBlock Text="{Binding Header}"   
        VerticalAlignment="Center" Margin="18 0 0 0"/> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
        </navigation:SfTreeNavigator.ItemTemplate> 
        <navigation:SfTreeNavigator.ItemContainerStyle> 
            <Style TargetType="{x:Type navigation:SfTreeNavigatorItem}"> 
                <Setter Property="IsEnabled" Value="{Binding IsEnable}"/> 
                <Style.Triggers> 
                    <Trigger Property="IsEnabled" Value="False"> 
                        <Setter Property="Background" Value="LightGray"/> 
                    </Trigger> 
                </Style.Triggers> 
            </Style> 
        </navigation:SfTreeNavigator.ItemContainerStyle> 
    </navigation:SfTreeNavigator> 
</Grid> 
 




MJ Mariusz Juszkiewicz March 6, 2021 06:59 AM UTC

I have an update to this solution.
I have started using Themes in my application. This style trigger overrides the Theme. For example when I use Office2019Black the text should be white, however, it show up as black
.
and it should look like this picture


VR Vijayalakshmi Roopkumar Syncfusion Team March 8, 2021 12:52 PM UTC

Hi Marius  
 
Thank you for your update. 
 
We have checked the reported behavior with SfTreeNavigator and we too able to observe that the text been displayed as Black. We are currently analyzing this behavior and update you the details on 10th March, 2021. 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Vijayalakshmi VR 



VR Vijayalakshmi Roopkumar Syncfusion Team March 10, 2021 11:58 PM UTC

Hi Marius 
 
Thank you for your update. 
 
We have checked the reported behavior "On applying the style for SfTreeNavigatorItem, it overrides the applied theme" and we observe that you need to apply basedon property for SfTreeNavigatorItem style, so only the text of SfTreeNavigatorItem looks white. However on applying the solution, we could face that background does not applied properly for SfTreeNavigatorItem, so we have fixed this internally and included this fix in our upcoming release Vol 1, expected to be rolled out by 17th March, 20201.  
 
Also please let us know your currently using version, if you need the patch , we will merge and update you the details accordingly. 
 
Regards, 
Vijayalakshmmi VR 



VR Vijayalakshmi Roopkumar Syncfusion Team March 12, 2021 03:30 PM UTC


The patch will be updated on 17th March, 2021

Regards,
Vijayalakshmi VR 



VR Vijayalakshmi Roopkumar Syncfusion Team March 18, 2021 03:10 AM UTC

Hi Marius,

Thank you for your patience.

We are still working on fixing the reported issue. As it requires changes in its implementation, we need more time to fix and ensure it in all the cases. We will fix and provide the patch by March 22, 2021.

We appreciate your patience until then.

Regards
Vijayalakshmi VR


VR Vijayalakshmi Roopkumar Syncfusion Team March 23, 2021 06:47 AM UTC

Hi Mariusz,

 

 

Thank you for your patience.

 

 

We have fixed the reported behavior “On applying the style for SfTreeNavigatorItem, it overrides the applied theme with SfTreeNavigator and patch for the same can be downloaded from following links. 

 

 

 

Recommended approach - exe will perform automatic configuration. 

 

 

 

Please find the patch setup from below location: 

 

 

 

Patch link : https://syncfusion.com/Installs/support/patch/18.4.0.30/613278/F153051/SyncfusionPatch_18.4.0.30_613278_3232021011155878_F153051.exe

 

 

 

 

 

Assemblies Link:   https://syncfusion.com/Installs/support/patch/18.4.0.30/613278/F153051/SyncfusionPatch_18.4.0.30_613278_3232021011155878_F153051.zip

 

 

 

 

 

Nuget link:    https://syncfusion.com/Installs/support/patch/18.4.0.30/613278/F153051/SyncfusionNuget_18.4.0.30_613278_3232021011155878_F153051.zip

 

 

 

Assembly Version: 18.4.0.30

 

 

 

Installation Directions: 

 

This patch should replace the files "Syncfusion.SfTreeNavigator.WPF” under the following folder. 

 

$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\[TargetFramework] 

 

Eg : $system drive:\Program Files\Syncfusion\Essential Studio\18.4.0.30\precompiledassemblies\18.4.0.30\4.6 

 

 

 

To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you must manually copy and paste them to the preferred location or you must run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies. 

 

 

 

https://www.syncfusion.com/support/directtrac/patches 

 

 

 

Please try this patch and let us know if it is resolved at your end.

 

 

 

Feedback Link:  https://www.syncfusion.com/feedback/23225/background-does-not-applied-properly-on-setting-the-style-for-sftreenavigatoritem

 

 

Regards, 

 

Vijayalakshmi VR


Loader.
Live Chat Icon For mobile
Up arrow icon