Click here to Skip to main content
15,503,456 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 0:33
mva#realJSOP30-Mar-21 0:33 
GeneralRe: UI not updating Pin
Richard Deeming29-Mar-21 22:36
mveRichard Deeming29-Mar-21 22:36 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 0:42
mva#realJSOP30-Mar-21 0:42 
GeneralRe: UI not updating Pin
Richard Deeming30-Mar-21 1:05
mveRichard Deeming30-Mar-21 1:05 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 6:12
mva#realJSOP30-Mar-21 6:12 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 13:14
mva#realJSOP30-Mar-21 13:14 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 15:26
mva#realJSOP30-Mar-21 15:26 
QuestionImpossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz22-Mar-21 15:05
Mc_Topaz22-Mar-21 15:05 
I have two WPF-applications. Let's call them A and B.

In A I wan't to start B as a new process and get the instance of B's MainWindow to further gain access of the controls in B.

When A has started it sets up an instance of the Process class to start B. The instance is kept in A to help in any other way to access or terminate B.

In A I have a StartB method and a GetB method:
C#
public partial class MainWindow : Window
{
    Process Process { get; set; }
        
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        StartB();
        GetB();
    }

    void StartB()
    {
        var path = @"C:\Some\Path\To\B.exe";
        var info = new ProcessStartInfo(path);
        Process = new Process();
        Process.StartInfo = info;
        Process.Start();
    }

    void GetB()
    {
        var title = Process.MainWindowTitle;
        var visual = System.Windows.Interop.HwndSource.FromHwnd(Process.MainWindowHandle);
        var window = visual.RootVisual as Window;
    }
}
The StartB method works. But the GetB method don't work.

This line in GetB returns null:
C#
var visual = System.Windows.Interop.HwndSource.FromHwnd(Process.MainWindowHandle);


I have googled and I found somewhere that the call to System.Windows.Interop.HwndSource.FromHwnd should work, but it didn't.

Is there a solution for this?


Best regards,
Stefan
AnswerRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Richard Deeming22-Mar-21 23:40
mveRichard Deeming22-Mar-21 23:40 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz23-Mar-21 5:02
Mc_Topaz23-Mar-21 5:02 
AnswerRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Gerry Schmitz23-Mar-21 8:27
mveGerry Schmitz23-Mar-21 8:27 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz23-Mar-21 13:22
Mc_Topaz23-Mar-21 13:22 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Richard Deeming24-Mar-21 0:14
mveRichard Deeming24-Mar-21 0:14 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Gerry Schmitz24-Mar-21 6:40
mveGerry Schmitz24-Mar-21 6:40 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz25-Mar-21 1:02
Mc_Topaz25-Mar-21 1:02 
QuestionWPF DataGrid Custom Group Header Pin
Kevin Marois22-Mar-21 9:47
professionalKevin Marois22-Mar-21 9:47 
AnswerRe: WPF DataGrid Custom Group Header Pin
Richard Deeming22-Mar-21 23:35
mveRichard Deeming22-Mar-21 23:35 
QuestionDynamic WPF DataGrid Pin
Kevin Marois19-Mar-21 11:41
professionalKevin Marois19-Mar-21 11:41 
AnswerRe: Dynamic WPF DataGrid Pin
Richard Deeming21-Mar-21 23:50
mveRichard Deeming21-Mar-21 23:50 
GeneralRe: Dynamic WPF DataGrid Pin
Kevin Marois22-Mar-21 8:07
professionalKevin Marois22-Mar-21 8:07 
GeneralRe: Dynamic WPF DataGrid Pin
Kevin Marois23-Mar-21 10:58
professionalKevin Marois23-Mar-21 10:58 
GeneralRe: Dynamic WPF DataGrid Pin
Richard Deeming24-Mar-21 0:13
mveRichard Deeming24-Mar-21 0:13 
GeneralRe: Dynamic WPF DataGrid Pin
Kevin Marois24-Mar-21 7:14
professionalKevin Marois24-Mar-21 7:14 
QuestionWPF with TPL Multithreading Pin
#realJSOP16-Mar-21 7:04
mva#realJSOP16-Mar-21 7:04 
AnswerRe: WPF with TPL Multithreading Pin
Gerry Schmitz16-Mar-21 8:45
mveGerry Schmitz16-Mar-21 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.