Show in Taskbar=false behavior - wpf

Hi I have one VSIX project. I have added a WPF form to that project for UI .
and set show in taskbar=false for that wpf window.While executing the project, it has been shown in the main window of experimental instance no issues with that. But when i switch over to another window and return back to the Experimental instance window the wpf window get disappeared.How can i fix this?

Finally the issue has been fixed by the below snippet.
Form = new MainWindow();
Form.Owner = Application.Current.MainWindow;
Form.ShowDialog();

Related

DotNetBrowser WinFormsBrowserView opening in tiny window within form

I followed the getting started tutorial for WinForms (https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000056958-quick-start-guide-for-winforms-developers).
I am using VS 2017 and .NET 4.6.1
Everything works great, but the browser window within the form is opening in a tiny window (approximately 50px square) with scrollbars and not taking up the full form. I've been scanning SO questions and the documentation and haven't found anyone reporting this before and I have not been able to understand how to configure this. Are there parameters for placing the control?
I tried using the 'UpdateSize' method, but that does not seem to do anything.
Has anyone else encountered this issue?
Hopefully this is a simple fix.
Thanks! Aaron
I figured it out. The BrowserView must be cast to a Control which then exposes many additional WinForm control properties such as DockStyle.
BrowserView browserView = new WinFormsBrowserView(BrowserFactory.Create();
Control browserWindow = (Control)browserView;
browserWindow.Dock = DockStyle.Fill;
Controls.Add(browserWindow);
In DotNetBrowser 1.16 and earlier versions WinFormsBrowserView.Dock property was set to DockStyle.Fill value by default.
In DotNetBrowser 1.17 and higher this property is set to DockStyle.None value by default.
Using the latest 1.19.1 even after replacing references multiple times.
WinFormsBrowserView does not show the .Dock property
Able to work around using this:
Public browser As Browser
Public browserView As BrowserView
browser = BrowserFactory.Create(BrowserType.HEAVYWEIGHT)
browserView = New WinFormsBrowserView(browser)
'browserView.dock = DockStyle.Fill '--this will not work so instead:
Dim obj As Control '--or Object
obj = browserView
obj.dock = DockStyle.Fill
If Controls.Contains(browserView) = False Then
'Controls.Add(browserView) '--Before
Controls.Add(obj) '--Now
There has to be a better solution. Please educate me.

Dialog Window for configuration in MVVM

i'm relative new to MVVM. My current problem is a modular dialog which should "autostart" at the beginning.
I've followed the example of WAFs Email Client for modular dialogs. Is it right that the only important thing is to set the Owner Property of the dialog to the instance of the main window of the application (and of course show the window with ShowDialog() instead of Show()?
If you close this dialog without configuration the application will shutdown. But now, if I open the main window in visual studios designer mode the configuration dialog comes up and if I close it visual studio crashes.
This is because I call the ShowDialog() of the configuration dialog in the constructor of my main windows view model.
To avoid this i can check for DesignerProperties.IsInDesignTool Property, but this is more a workaround as good code style, right?
Do you have any suggestions? Thanks.
The problem here is that you are showing a dialog in the constructor of a class. That's something you don't want to do.
I would solve it like this:
Don't specify a StartupUri in your app.xaml but override OnStartup. There you check whether the configuration dialog should be shown or not. If it should be shown, show it and after it has closed with OK, show you main window.
Something like this:
override void OnStartup(...)
{
if(configurationNotComplete)
{
ConfigDialog cfg = new ConfigDialog();
if(!(cfg.ShowDialog() ?? false))
{
Shutdown();
return;
}
}
MainWindow window = new MainWindow();
window.Show();
}
You have another problem with your current approach: Your ViewModel shows a modal dialog. This means it knows at least about one View: That of the modal dialog. MVVM is one way: The View knows about the ViewModel, the ViewModel knows about the Model. There should be no connection in the other direction.

Weird scrollbar UI in hosted WPF composite control

My windows forms application hosts AvalonEdit (the composite WPF control in question) in one of its forms to cater to its text editing requirements. Here's the code I use:
WPFHost = gcnew ElementHost();
TextField = gcnew AvalonEdit::TextEditor();
WPFHost->Dock = DockStyle::Fill;
WPFHost->Child = TextField;
TextField->Options->AllowScrollBelowDocument = false;
TextField->Options->EnableEmailHyperlinks = false;
TextField->Options->EnableHyperlinks = true;
TextField->Options->RequireControlModifierForHyperlinkClick = true;
TextField->ShowLineNumbers = true;
ContainerControl->Controls->Add(WPFHost); // the container is a panel
The code compiles and executes fine, except for the scrollbars - http://dl.dropbox.com/u/2584752/avalonEditBug.png . Right clicking on what's left of the bar raises an ArgumentOutOfRange exception.
Strangely, I wasn't able to reproduce the issue when I tried hosting the control in a newly created sample project. 'mI using the latest build of the text editor and have all the requisite assemblies installed.
EDIT: Wrapping the editor in a usercontrol doesn't help either.
You say that the control works fine in a new/blank project but fails in the one you need makes me wonder about conflicts more than anything. In the project you're really wanting compared to the project it worked in what are the differences? .NET version? Referencing an assembly from a directory in one but out of the GAC in another?
It's hard to say that the control is messing up for you when you've got it working elsewhere, so the only thing I can suggest is just dive deep into the differences of the two projects.
Good luck.
This looks like a layout error to me. Maybe WPFHost measures the TextField unexpectedly.
I can suggest setting specific Width and Height on the TextField itself. If this fixes the problem you can adjust those as the size of the WPFHost control changes or try setting the MaxHeight/Width, sometimes they help and save some code for Width/Height updates.
try to create a WPF grid as a child of ElementHost, and place the editor inside that grid. On Other way, is to create an UserControl have the editor in that control and use the control inside your Winform app. Such approach helped me a couple of times.
I've implemented a workaround for the issue as mentioned in this thread [ Synchronizing a WPF ScrollViewer with a WinForms ScrollBar ].

Visual Studio 2010: using a winforms user control in a VSPackage Tool Window

when creating a simple VSPackage with a Tool Window a sample WPF user control is created and added to the Tool Window.
Must this user control be of WPF? i have a winforms user control and, when adding it to the tool window it's not getting displayed. tried hosting it in WPF with no success. is there any standard way of doing this?
I faced the same issue. Searched a lot. Was not able to find the answer or sample. Finally posted on msdn forum. Got my answer. Here is the link to the thread of msdn forum
MSDN Forum thread link
The ToolWindowPane can be used to host WPF content or a Winform control.
For a Winform control, you just need to override the Window property get, and leave the Content property null.
For example:
public MyToolWindow() : base(null)
{
this.Caption = Resources.ToolWindowTitle;
this.BitmapResourceID = 301;
this.BitmapIndex = 1;
control = new MyControl();
}
override public System.Windows.Forms.IWin32Window Window
{
get
{
return (System.Windows.Forms.IWin32Window)control;
}
}
I'm almost certain it can be winforms too, and I'm sure there's a demo somewhere on MSDN. I'll see if I can dig it up sometime.

WPF ShowDialog and ElementHost

is it possible to display a Modal Window from a WPF User Control, that is a child of an ElementHost, and set the owner/parent of the Modal Window to the containing Form control?
I'm guessing you can't do this, as the Owner property takes an instance of Window, where as I want to set it to the parent of the Element Host control, which is an old Windows Forms Form control. Just wondering if there is a work around or alternative approach.
The problem is when the Modal Window is displayed and the user switches to another application, then back again, the Modal Window is hidden and the user is unable to interact with the main Window. This is due to Windows thinking the Modal Window is still displayed, when it isn't, as there is no Owner/Parent relationship set.
Cheers,
James.
I'm using WindowInteropHelper to solve that problem like this:
var wpfDialog = new MyWpfDialog();
var interopHelper = new WindowInteropHelper(wpfDialog)
{
Owner = winFormsDialog.Handle
};
wpfDialog.ShowDialog();
I know this post is old, but I came across a way to find the winform window that is hosting the ElementHost from the context of a wpf UserControl where you may not have access to the winform window. I found this to be useful so that I don't have to pass the host window around.
HwndSource winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(wpfControlInElementHost) as System.Windows.Interop.HwndSource);
if (winformWindow != null)
{
var interopHelper = new WindowInteropHelper(wpfWindow)
{
Owner = winformWindow.Handle
};
}
Ok just found the solution using WindowInteropHelper.
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/44c903fb-9514-401c-ba85-58acd5293c1b

Resources