Skip to content

Creating an automatic data template fails, if the UI dispatcher changes #965

@flagbug

Description

@flagbug

I'm on WinRT and have created an app that is a share target

It seems like each time the app is opened as share target, it gets assigned a new UI dispatcher, while the AppDomain persists.

This is a problem, when creating the automatic DataTemplate at

public static Lazy<DataTemplate> DefaultItemTemplate = new Lazy<DataTemplate>(() => {
, since it's lazy and persists over the AppDomain and the first UI dispatcher gets cached in the DataTemplate.

When the dispatcher then changes, and the template with the old dispatcher is assigned to a control that was created on the new UI thread, line

itemsControl.ItemTemplate = DefaultItemTemplate.Value;
will result in a weird COM exception "COM object that has been separated from its underlying RCW cannot be used" (At least on WinRT)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions