Is there any difference in x:name and name for controls in xaml file?

In Brief Yes there is a difference. The bottom line is that x:Name can be used on object elements that do not have Name properties of their own. A longer explanation You can only use Name on an element that represents an object that actually does have a Name property. For example anything that derives … Read more

Access ResourceDictionary items programmatically

Got it solved. I needed to: load my resource dictionary merge it with the application’s resources load my control template from the application resource As part of loading the resource dictionary, i also had to register the pack URI scheme. I then had to deal with some crazy COM based exceptions due to slight errors … Read more

Invalid cross-thread access issue

In order to update a DependencyProperty in a ViewModel, use the same dispatcher you would use to access any other UIElement: System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => {…}); Also, BitmapImages have to be instantiated on the UI thread. This is because it uses DependencyProperties, which can only be used on the UI thread. I have tried instantiating BitmapImages on … Read more

Sync SelectedItems in a muliselect listbox with a collection in ViewModel

So, assume you have a ViewModel with the following properties: public ObservableCollection<string> AllItems { get; private set; } public ObservableCollection<string> SelectedItems { get; private set; } You would start by binding your AllItems collection to the ListBox: <ListBox x:Name=”MyListBox” ItemsSource=”{Binding AllItems}” SelectionMode=”Multiple” /> The problem is that the SelectedItems property on ListBox is not a … Read more