SelectionVisual

4 posts, 1 answers
  1. Paul Gallen
    Paul Gallen avatar
    156 posts
    Member since:
    Jun 2008

    Posted 14 Nov 2008 Link to this post

    Hi,

    Can you help. I am trying to write a style for the radTreeViewItem; 'SelectionVisual'. Can you give me a small xaml example, to get me started.

    Thanks


    P
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 18 Nov 2008 Link to this post

    Hi Paul,

    Please find attached a project that contains the themes for all the controls. Feel free to modify the TreeView themes as you need. Unfortunately you need to do that manually due to current problems with the Blend support.

    In order to change the SelectionVisual you need to edit the $MyCustomTheme/Themes/TreeView.xaml file and to change the "SelectionVisual" element that is on line 533.

    Please let us now if you need more help on that.

    All the best,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Answer
    Paul Gallen
    Paul Gallen avatar
    156 posts
    Member since:
    Jun 2008

    Posted 19 Nov 2008 Link to this post

    Thanks Valentin,

    Since I am new to XAML and still grasping concepts, I simply have no idea what to change. Can you give me an example of changing the selectionVisual just as an example.

    Thanks

    P
  4. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 20 Nov 2008 Link to this post

    Hello Paul,

    As our colleague Valentin has already sent all the code, I will just explain what you should do to reach the desired result. Please follow the plan explained bellow:

    1. First let us change the application's content - copy the attached RadWindowBlend.xaml file over the existing one in TelerikThemingApplication project - there is a simple Tree with some items.

    2. I highly advise you to preview the Common.xaml file from MyCustomTheme project - this is the place where we hold definitions for all common brushes used in our controls. You can edit these brushes in order to recolor RadControls - this approach is addressed in Tweaking the Theme colors article.

    3. Preview the TreeView.xaml file (from the Valentin's archive). Especially look at following places:
      - rows 7 and 31 where the SelectedBrush brush is preloaded as a TreeView resource:


      - the row 533 where the usage of the SelectedBrush brush is scripted as main part of SelectionVisual element:


    4. One easy way to change the look of selected tree item is to change the SelectedBrush brush in TreeView.xaml file - just clean the row 31 and define a new SelectedBrush brush. In the attached archive in the Step4 folder you can find such a file - just copy it over the existing one in the MyCustomTheme project and preview the result.

    5. The second way is to change the SelectionVisual element directly at row 533 (as it is done in file located in the Step5 folder from the attached archive).

    6. And finally you can change the TreeViewItem's template completely in order to conform the task you are working on. For example you can preview the code inside the Lookless TreeView example.

    Paul, please give it a try and let us know if there are other questions.

    Regards,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top