WPF Icon for all app windows - wpf

It is possible to set one Icon so, that it would be used on every window in current app. So that i set it once (not on every window by hand)..?

A good reference on the subject is here MSDN. States that you have an Icon for the Application (Desktop Icon), and one for each Window.
A WPF window always displays an icon. When one is not provided by setting Icon, WPF chooses an icon to display based on the following rules:
Use the assembly icon, if specified.
If the assembly icon is not specified, use the default Microsoft Windows icon.
Community Content Reference:
"A liitle tip : if you set the application icon and expect to see it on the window - it wont show up if running in debug from VS. Running externally or without attaching (ctrl + f5) the icon displays as expected."

Set the icon in the project properties on the "Application" tab in the "Resources" section. This icon will be the default icon for all windows in the application.

Under VS2010 open the Properties for the main application executable and open the Application tab. Set the icon under 'Icon and Manifest' in the Resources section.
To see the icon while debugging under VS2010 you need to open the Debug tab and uncheck the option for 'Enable the Visual Studio hosting process', otherwise you will only see the default icon on most windows.
I assume that the icon loading code is getting confused by the hosting process and is looking in "someapplication.vshost.exe" instead of "someapplication.exe" for the icons.
This looks like it's fixed in VS2013.

The reason that "Enable the Visual Studio hosting process" makes the icon not work is that it is started using the vshost.exe, and thereby the manifest is not read properly.
The same goes if you have other stuff in the manifest, like regfree ocx controls etc that requires the manifest to load.

You can also try this to set your own icon:
private void Page_Loaded_1(object sender, RoutedEventArgs e)
{
Uri iconUri = new Uri(#"C:\Apps\R&D\WPFNavigation\WPFNavigation\Images\airport.ico", UriKind.RelativeOrAbsolute);
(this.Parent as Window).Icon = BitmapFrame.Create(iconUri);
}

Related

No Resources window .Net Core WPF project in Microsoft Blend 2019

I am having an issue with Blend for Visual Studio 2019 version 16.11.3. When I create a .Net Framework project I can access the Resource Window via the "View" toolbar at the top.
However I seem to be unable to access the same window when the project is using .Net Core.
I am having trouble figuring out where and why the Resources window might be hidden? I want this functionality to make it easier to apply styles using the interface and just drag&dropping styles vs writing them out in xaml.
You could follow the steps below to display the Resources Window menu.
Click Customize... under the Tools menu.
Click Commands and select Menu bar as View.
Click Add Command... ->Select View and Resources Window on the Add Command page and click OK.
Click Close on the Customize page.
Then you could see the Resources Window under the View menu.

Is it possible to make a Window as the SplashScreen for WPF Project

When I use the AddNewItem to add an splash screen to a project, It adds an image file to the project. But I want to know if it is possible to make a Window as the Splash Screen of a WPF project.
I tried to set the BuildAction property of a Window to SplashScreen but the project fails to compile.
The Andy Lang apparently explained to make the splash screen with this single steps.
Please refer
http://www.codeproject.com/Articles/38291/Implement-Splash-Screen-with-WPF
You need to create a normal window, put an image inside the window, and show and hide it at appropriate times. No such thing as 'Splash Screen' exists it .NET.

Ensure WPF Taskbar Window Preview is actualized

How can I ensure that the hower preview of my WPF application (.net 4) is refreshed when the user places the mouse over the taskbar icon.
I have an app that visualizes some status values. If the app window is minimized and the user hovers over the taskbar button, the preview window that is shown shows the last view of the window at which the window was active. However I would like to have an actualized view.
Is there a possiblity to achieve that?
I believe you'd need to customize the preview, as described here (under the Customizing Preview section). Which leverages the Windows API Code Pack for Microsoft® .NET Framework.
An example can be found here, but looks like:
TabbedThumbnail preview = new TabbedThumbnail(parentForm.Handle, childForm.Handle);
TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);
preview.TabbedThumbnailBitmapRequested += (o, e) =>
{
Bitmap bmp = new Bitmap(width, height);
// draw custom bitmap...
e.SetImage(bmp);
e.Handled = true;
};
Another example, can be found here which states:
The CustomWindowsManager class
provides an abstraction of a
customized window thumbnail preview
and live preview (peek), including the
facilities to receive a notification
when a preview bitmap is requested by
the Desktop Window Manager (DWM) and
to automatically grab the preview
bitmap of a window.
The download link for this code is here, which includes the CustomWindowsManager class. This appears to provide the live preview.
You probably can't. Windows 7 pipes the graphics of an open window to the live preview from the Taskbar. It can't know what the window now looks like while it is minimized because it isn't being drawn at all.
I guess it's not impossible to do custom thumbnails. Aside from CodeNaked's answer, I also found this article, which even includes multiple thumbnails from the same app.

"Please wait" Windows in WPF

I need to create a "please wait" window at the start up of my application, start animation and at the lifetime of app change visibility. I don`t want create explicitly new thread (Maybe ThreadPool or BackgroundWorker).
Any ideas?
WPF has a very nice splash screen class exactly for that: http://www.codeproject.com/Articles/36418/WPF-Splash-Screen.aspx
Here is the quick steps:
Add the image file to the WPF Application project. For more information, see How to: Add Existing Items to a Project.
In Solution Explorer, select the image.
Add the image file to the WPF Application project. For more information, see How to: Add Existing Items to a Project.
In the Properties window, click the drop-down arrow for the Build Action property.
Select SplashScreen from the drop-down list
(source here: WPF SplashScreen implementing)

Show Background Image While Loading Silverlight Application

I have a Silverlight app that takes a few seconds to display on a webpage. While loading, the user sees a blank space. Is there a way to show some sort of alt text or background image behind the application while it is loading to indicate to the user what is happening?
Check that out :
http://msdn.microsoft.com/en-us/library/cc903962(VS.95).aspx
Based on the above link posted by danbord, I found that this can be accomplished via a splash screen. Basically, the splash screen will be loaded while the .xap is still being downloaded for a silverlight application. This can be implemented as follows:
Create splash screen .xaml file (this can be done in Visual Studio by creating a Silverlight 1.0 JScript page)
Add a splashScreenSource parameter to your object tag in the webpage hosting your silverlight application. This should point to the .xaml file created in step 1.
It is important that the value of the splashscreen param resolve to the correct location of the .xaml file relative to the page the silverlight app is hosted in. For example, if your SplashScreen.xaml file is in your website root, but the page hosting your silverlight app is in a subfolder, you will need to use
<param name="splashScreenSource" value="../SplashScreen.xaml" />
There are also other options that can be added such as attaching an event handler to the onSourceDownloadProgressChanged event to update a progress bar or some other UI animation.

Resources