Try to invoke your code from the dispatcher:
Application.Current.Dispatcher.Invoke((Action)delegate{
// your code
});
More Related Contents:
- Difference between SelectedItem, SelectedValue and SelectedValuePath
- Binding ConverterParameter
- {x:Null} vs. Transparent?
- WPF Attached Property Data Binding
- How can I get ScrollViewer to work inside a StackPanel?
- Why are ActualWidth and ActualHeight 0.0 in this case?
- WPF: Canvas mouse events not firing on empty space
- How do I convert a Color to a Brush in XAML?
- What is the difference between x:Reference and ElementName?
- Are “{Binding Path=.}” and “{Binding}” really equal
- XAML Combine styles going beyond BasedOn?
- How can I style the border and title bar of a window in WPF? [duplicate]
- WPF Some styles not applied on DataTemplate controls
- WPF – Global Style?
- How to open a WPF Popup when another control is clicked, using XAML markup only?
- How to format number of decimal places in wpf using style/template?
- WPF Animation “Cannot freeze this Storyboard timeline tree for use across threads”
- How to create trapezoid tabs in WPF tab control
- Implement INotifyPropertyChanged on generated Entity Framework classes
- How to autosize and right-align GridViewColumn data in WPF?
- WPF C# button style
- Binding [VisualStateManager] view state to a MVVM viewmodel?
- Advanced XAML Animation effects. Pulse, Marching ants, Rotations. Alerts
- Binding in WPF to element of array specified by property
- Is it possible to initialize WPF UserControls in different threads?
- Create a control in Resources and reuse it in XAML WPF
- How exactly do Attached Properties work in WPF?
- Adding a Merged Dictionary to a Merged Dictionary
- Bind a property to DataTemplateSelector
- How do I dynamically bind and statically add MenuItems?