This is a migrated thread and some comments may be shown as answers.

Populate a tile style from resource dictionary

1 Answer 104 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
band asked on 10 Aug 2016, 03:47 PM
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.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 12 Aug 2016, 03:35 PM
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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question