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

Populate a tile style from resource dictionary

1 Answer 101 Views
TileList
This is a migrated thread and some comments may be shown as answers.
band
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;       
    Tiles.Add(tile);
}


app.xaml

<telerik:Tile x:Key="Calendar" TileType="Double" Background="#FF79256B" Group="Other">
    <telerik:RadCalendar x:Name="calendar"
                  FontFamily="Segoe UI"
                  FontSize="10"
                  controls:StyleManager.Theme="Windows8"
                  VerticalAlignment="Top" HorizontalAlignment="Center"
                  SelectionMode="Extended"
                  IsTodayHighlighted="True" ViewsHeaderVisibility="Collapsed"                                    
                  SelectedDate="{Binding SelectedDate, Mode=TwoWay}"
                  Culture="en-US"
                  DayTemplateSelector="{StaticResource EventDayTemplateSelector}"/>
</controls:Tile>

 

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
0
Martin
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.

Regards,
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.
Tags
TileList
Asked by
band
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or