Populate a tile style from resource dictionary

2 posts, 0 answers
  1. band
    band avatar
    6 posts
    Member since:
    Jun 2016

    Posted 10 Aug Link to this post

    At the moment in my resource dictionary I have a telerik Tile control. When it's instantiated a second time I receive the follow error `Specified Visual is already a child of another Visual or the root of a CompositionTarget`

    public void ListIcon()
        var tile = Application.Current.Resources["ListTile"] as Tile;       


    <telerik:Tile x:Key="Calendar" TileType="Double" Background="#FF79256B" Group="Other">
        <telerik:RadCalendar x:Name="calendar"
                      FontFamily="Segoe UI"
                      VerticalAlignment="Top" HorizontalAlignment="Center"
                      IsTodayHighlighted="True" ViewsHeaderVisibility="Collapsed"                                    
                      SelectedDate="{Binding SelectedDate, Mode=TwoWay}"
                      DayTemplateSelector="{StaticResource EventDayTemplateSelector}"/>


    Everytime a new user is logged in, ListIcon() is called. If I log out and log into a second user the error occurs. May I ask how do I resolve this.

  2. Martin Vatev
    Martin Vatev avatar
    74 posts

    Posted 12 Aug Link to this post

    Hello Band,

    By default, every visual element declared as a resource in ResourceDictionary is sharing the same instance for all requests. If you want to change this behavior and create a new instance for each request you can set x:Shared attribute of the current visual element to False. But keep in mind that this attribute is valid only for WPF.

    I hope that this helps.

    Martin Vatev
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top