Change Checked Items to Bold

5 posts, 0 answers
  1. George
    George avatar
    3 posts
    Member since:
    Oct 2011

    Posted 16 Oct 2011 Link to this post

    How can i change the checked items and it’s ancestors to bold font?

    Thanks in advance.

     

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Oct 2011 Link to this post

    Hi George,

     I prepared a sample for you that meets your requirement in DataBinding scenario. I bind the FontWeight property of the TextBlock from the ItemTemplate to a CheckedState property of the ViewModel. The CheckState of the RadTreeViewItems is bound to the CheckedState via ContainerBindings. Please note that you need the child items expanded before checking their parent. Do not hesitate to ask if you need further assistance.

    Regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. George
    George avatar
    3 posts
    Member since:
    Oct 2011

    Posted 19 Oct 2011 Link to this post

    Hi Petar,

    Thanks for your response, I think some files are missing from the zip. Could not find the "TreeView.csproj" file. Can you please zip again and send to me?

    Thanks

    Edit:
    Please ignore this. I am able to see the files.
  5. George
    George avatar
    3 posts
    Member since:
    Oct 2011

    Posted 19 Oct 2011 Link to this post

    Hi Petar,

    That was excellent. Thanks for the code snippet.

    I have few more conditions to add this scenario.

    1. According to the business requirement I have IsTriStateMode = “false”
    2. Like I asked initially I would like to have the ancestors of the checked item also shown as bold.  
    3. I would like to do this change (bold/normal)in view (either in .xaml or .cs file)
    4. I have ViewModel defined in the following way, which makes changes to the property of an object does not reflect back to UI. In other words unless I refresh the entire Hierarchy object the changes inside this object does not take effect to UI.

     

    Model

     

       public class Hierarchy

        {

            public string Name { get; set; }

            public Guid Id { get; set; }

            public Guid ParentId { get; set; }

            public ObservableCollection<Hierarchy> ChildCollection { get; internal set; }

            public ToggleState ToggleState { get; set; }

        }

     

    ViewModel

     

        public class HierarchyViewModel : ViewModelBase

    {

            public ObservableCollection<Hierarchy> Hierarchy

            {

                get

                {

                    return this.hierarchy;

                }

     

                private set

                {

                    if (this.hierarchy != value)

                    {

                        this.hierarchy = value;

                        RaisePropertyChanged("Hierarchy");

                    }

                }

            }

    }

     Looking forward for your solution on this scenario,

    Thanks

  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 24 Oct 2011 Link to this post

    Hi George,

     I modified  the last solution I gave you in the following way:
      1.Set the IsInTriStateMode to false;
      2. The Hierarchy class now inherits the ViewModelBase and when the ToggleState is changed the UI is notified.
      3. When the ToggleState is set to On, all the children nodes' ToggleStates are also set to On. This way we implement a kind of partial TriState behavior. It should be easily corrected if needed (with code only in the ViewModels).

    private ToggleState toggleState;
     
           public ToggleState ToggleState
           {
               get { return toggleState; }
               set
               {
                   toggleState = value;
                   if (value == ToggleState.On)
                   {
                       foreach (var item in ChildCollection)
                       {
                           item.ToggleState = ToggleState.On;
                       }
                   }
                   this.OnPropertyChanged("ToggleState");
               }
           }


    Please let us know if this satisfies you.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner