I have windows form application in C#. I have class library for WPF user control. And I am using that in Windows Form App using Element Host. Now in WPF User control i need to show one message using MessageBox. it's working but displayed modeless on Main Form of Windows Form Application. I want to Show this Message box as model.
Any help please.
Edits:
let me Explain by example: I have “WindowsFormApp1” Another is “WPFUserCtrlLib” which is class library. And it has UserControl named as “WPFUserCtrl” so I have “WPFUserCtrl.xaml” and “WPFUserCtrl.xaml.cs” Files. In WindowsFormApp1 I have MainForm named “Form1”. In Form1 I am using “WPFUserCtrl” using Element Host. Now there is some logic resides in “WPFUserCtrl.xaml.cs” say
String ErrorMsg=“Error There”;
if(condition)
{
//Do Task
}
else
{
MessageBox.Show(ErrorMsg);
}
So here I need to show ErrorMsg. When this MessageBox is displayed, it is modeless as I am able to access controls on “Form1” like menus, buttons and all.
I have tried lot. Couldn't get solution so posted question here and continued to try again with diff approach. And Now I found the solution.
Solution is: use Dispatcher.Invoke
Now my MessageBox is model.