Task continuation on UI thread

Is there a ‘standard’ way to specify that a task continuation should run on the thread from which the initial task was created? Currently I have the code below – it is working but keeping track of the dispatcher and creating a second Action seems like unnecessary overhead. dispatcher = Dispatcher.CurrentDispatcher; Task task = Task.Factory.StartNew(() … Read more

WPF Databinding: How do I access the “parent” data context?

I have a list (see below) contained in a window. The window’s DataContext has two properties, Items and AllowItemCommand. How do I get the binding for the Hyperlink‘s Command property needs to resolve against the window’s DataContext? <ListView ItemsSource=”{Binding Items}”> <ListView.View> <GridView> <GridViewColumn Header=”Action”> <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel> <TextBlock> <!– this binding is not working –> … Read more

Bring a window to the front in WPF

How can I bring my WPF application to the front of the desktop? So far I’ve tried: SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetForegroundWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle); None of which are doing the job (Marshal.GetLastWin32Error() is saying these operations completed successfully, and the P/Invoke attributes for each definition do have … Read more