Click here to Skip to main content
15,885,141 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: AvalonEdit Sytax Highlighting for XAML files? Pin
Richard Deeming6-Apr-21 0:22
mveRichard Deeming6-Apr-21 0:22 
QuestionRevert Property Change Pin
Kevin Marois5-Apr-21 7:20
professionalKevin Marois5-Apr-21 7:20 
AnswerRe: Revert Property Change Pin
#realJSOP5-Apr-21 8:55
mve#realJSOP5-Apr-21 8:55 
QuestionUI not updating Pin
#realJSOP28-Mar-21 3:52
mve#realJSOP28-Mar-21 3:52 
AnswerRe: UI not updating Pin
Pete O'Hanlon28-Mar-21 6:10
mvePete O'Hanlon28-Mar-21 6:10 
GeneralRe: UI not updating Pin
#realJSOP28-Mar-21 6:40
mve#realJSOP28-Mar-21 6:40 
AnswerRe: UI not updating Pin
Richard Deeming28-Mar-21 22:20
mveRichard Deeming28-Mar-21 22:20 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 2:59
mve#realJSOP29-Mar-21 2:59 
AnswerRe: UI not updating Pin
Gerry Schmitz29-Mar-21 9:15
mveGerry Schmitz29-Mar-21 9:15 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 10:38
mve#realJSOP29-Mar-21 10:38 
GeneralRe: UI not updating Pin
Gerry Schmitz29-Mar-21 11:24
mveGerry Schmitz29-Mar-21 11:24 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 12:07
mve#realJSOP29-Mar-21 12:07 
GeneralRe: UI not updating Pin
Gerry Schmitz29-Mar-21 12:19
mveGerry Schmitz29-Mar-21 12:19 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 23:33
mve#realJSOP29-Mar-21 23:33 
GeneralRe: UI not updating Pin
Richard Deeming29-Mar-21 21:36
mveRichard Deeming29-Mar-21 21:36 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 23:42
mve#realJSOP29-Mar-21 23:42 
GeneralRe: UI not updating Pin
Richard Deeming30-Mar-21 0:05
mveRichard Deeming30-Mar-21 0:05 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 5:12
mve#realJSOP30-Mar-21 5:12 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 12:14
mve#realJSOP30-Mar-21 12:14 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 14:26
mve#realJSOP30-Mar-21 14:26 
QuestionImpossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz22-Mar-21 14:05
Mc_Topaz22-Mar-21 14: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 22:40
mveRichard Deeming22-Mar-21 22:40 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz23-Mar-21 4:02
Mc_Topaz23-Mar-21 4:02 
AnswerRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Gerry Schmitz23-Mar-21 7:27
mveGerry Schmitz23-Mar-21 7:27 
GeneralRe: Impossible? Get instance of MainWindow from extern WPF-application Pin
Mc_Topaz23-Mar-21 12:22
Mc_Topaz23-Mar-21 12:22 

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.