I have a Gui popup with a team binding,
<Grid x:Name="popup" Visibility="Hidden" DataContext="{Binding Path=PopupMsg}" > <TextBlock x:Name="tbMessage" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Margin="20,70,10,0" Text="{Binding Path=Message}" FontSize="16"/> <Button x:Name="btnPopupOk" Grid.Row="1" Grid.Column="2" Content="{Binding Path=OkContent}" Margin="10,40,10,10" Command="{Binding}" CommandParameter="true" /> </Grid> </Border> </Grid>
in a C # file, I link the command:
CommandBinding okCommandBinding = new CommandBinding(OkCommand); okCommandBinding.Executed += popupButtons_Executed; okCommandBinding.CanExecute += okCommandBinding_CanExecute; CommandBindings.Add(okCommandBinding); btnPopupOk.Command = OkCommand;
It works fine when I use it from the same topic, when I get a callback from a web service that is in a different thread, I use a dispatcher to display a message, I can see new text in a popup, but the binding isnβt the working button remains unavailable (CanExecute = false). When I click on the screen with the mouse, the popup updates the actual CanExecute value and a button appears.
System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate() { popup.Visibility = Visibility.Visible; popup.Focus(); }));
source share