Hide TileGroup using MVVM

4 posts, 0 answers
  1. Rémi
    Rémi avatar
    24 posts
    Member since:
    May 2015

    Posted 12 Jan Link to this post

    Hi,

    I would like to hide a TileGroup depending on a property in my ViewModel, I mean something like this :

    <telerik:TileGroup Header="Header" Visibility={Binding MyProperty, Converter={StaticResource BooleanToVisibility}} />

    Is there a way to achieve this ?

     

    Thanks,

    Rémi.

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    281 posts

    Posted 14 Jan Link to this post

    Hi Rémi,

    Unfortunately, there is no Visibility property of the TileGroup which value you can directly use for binding. Can you please clarify what exactly your intentions are? Would you like to hide the Group header or all the items within this specific group?  

    If you would like to set the visibility of all items within a certain group, you can use an approach similar to the following one:
    foreach (var item in this.TileList.Items)
       {
           var actualItem = item as Tile;
           if (actualItem.Group.Header.ToString() == "Group1")
           {
               actualItem.Visibility = Visibility.Collapsed;
           }  
       }

    Rémi, please provide more details on the behavior you are aiming for so we can consider the different options. I have attached a sample project to my reply. You can modify it so that it reflects your setup and send it over so we can further advise.

    I am looking forward to your reply.

    Regards,
    Stefan Nenchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rémi
    Rémi avatar
    24 posts
    Member since:
    May 2015

    Posted 14 Jan in reply to Stefan Nenchev Link to this post

    Hi Stefan,

    I would like to hide the entire group, I mean the GroupHeader and the Tiles within. I wish to perform this to use only Xaml bound by a business property (as I illustrated in my first post) but I guess it's not possible at the moment.

    How could I perform this if I want to respect the MVVM pattern ?

    Rémi.

  5. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    281 posts

    Posted 19 Jan Link to this post

    Hello Rémi,

    As advised, It will not be possible to achieve this through XAML only as there is no such property of the TileGroup that you can use. However, you should be able to achieve the desired behavior through commands which will not break the MVVM principles in any way. I have refactored the sample project so that it hides the group through a command instead of using the code behind and also hiding the group header.

    Regards,
    Stefan Nenchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top