tags:

views:

38

answers:

2
    void Start()
{
System.Windows.Controls.Primitives.Popup p = new System.Windows.Controls.Primitives.Popup();
    p.HorizontalOffset = this.ActualWidth / 2;
    p.Width = 100;
    p.Height = 100;
    p.VerticalOffset = this.ActualHeight / 2;
    DockPanel dock = new DockPanel();
    dock.Children.Add(new Button() { Content = "Обновлено" });
    p.Child = dock;
    p.IsOpen = true;
    Thread t = new Thread(StopPopup);
    t.Start(p);}

function:

private void StopPopup(object obj)
        {
            try
            {
                System.Windows.Controls.Primitives.Popup p = (System.Windows.Controls.Primitives.Popup)obj;
                this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                {
                    dataGrid1.DataContext = DataSetCreator.AllItems();
                    Thread.Sleep(1500);
                    p.IsOpen = false;

                }));
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

but why this code is triggered once = ( }

A: 

It looks like you're trying to show a control from a non-UI thread and not connecting it to the Application UI in any way (as far as I can see here). WPF UI elements need to created and manipulated on the UI thread and need to be associated with some Window based control in order to be rendered.

John Bowen
A: 

In addition to what John said, I would suggest looking at a Modeless dialog box. When you call Show() on the dialog box, the method returns immediately. This allows the application to continue instead waiting for a response from the dialog. You can also attach to button's click event so you know when the button is clicked.

WanderingThoughts