I started using MahApps.Metro just yesterday, and I can't figure out how to get application icon to show as window icon on a window (or better, all of them). Here in the example window icon is included, but I can't seem to get it. When I use
ShowIconOnTitleBar="True"
it doesn't do anything.
What am I doing wrong?
You need to set the Iconproperty like this example (taken from the Mahapps demo app) :
<Controls:MetroWindow x:Class="MetroDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="MahApps.Metro - Demo Application"
Width="960" Height="600"
Icon="mahapps.metro.logo2.ico"
ShowIconOnTitleBar="True"
ShowTitleBar="True">
<Grid />
</Controls:MetroWindow>
I suggest that you download the source code for the Mahapps project, which also contains the source for a demo app (too bad they don't advertise it on their website), it's great for examples. You can find it on GitHub here
Related
I have what is as yet a very minimal (just started) WPF app that uses Bing Maps. This is all there is to it so far:
<Window x:Class="DataMapper.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Data Mapper" Height="532" Width="798" WindowStartupLocation="CenterScreen" >
<Grid>
<m:Map x:Name="dataMapper" ZoomLevel="10" CredentialsProvider="MyKeyWhichWorksInWindows8Apps" Mode="Aerial" ></m:Map>
</Grid>
</Window>
Yet, when I run it does display a map (very faintly, I might add), but it is unresponsive/hangs. I had to Ctrl+Alt+Delete to get it to shut down.
Try using the updated WPF control which has a bunch of bug fixes: http://www.microsoft.com/en-us/download/details.aspx?id=27165
There is also a Nuget package available now: https://www.nuget.org/packages/Microsoft.Maps.MapControl.WPF/1.0.0.3
I am using MEF, Prism and WPF. I have a simple module (for now, I'll do more with it when I get past this roadblock) that displays a single image sourced as static resource in that module. Here is the xaml for the view:
<UserControl x:Class="SplashScreenModule.SplashView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Height="960" Width="1180">
<Grid>
<Label>
<Image Source="Images/My Image.png"/>
</Label>
</Grid>
The image shows up in the designer but when I run the code the window is blank. If I replace the image with simple text the text is display as expected.
<Label>
This shows up in the window.
</Label>
I've spent the last 3 hours trying to figure this out and am stumped. I would appreciate any help.
Thanks,
Bill
You have to know that there is a difference on how ressources are managed at DesignTime and at RunTime. At DesignTime there is no compilation required, thus it is able to display a ressource even if it is not include in the project.
At runtime this is normally possible, but it is better to include the ressources in your project (ie create a folder Images in your solution, and add the "My Image.png" in this folder), to be sure of the location of your ressource compared to your exe.
If you do it and the image still doesn't show up, try to remove the label and execute again.
By doing this it works fine for me. As soon as the image show up, you can add back the label.
Hope it helps.
The following code is working for me:
<Window x:Class="LabelImage.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Label>
<Image Source="Images/visual studio.png" />
</Label>
</Grid>
</Window>
I structured my solution like you did: I have the picture inside a folder named Images. The MainWindow is located directly under the project node (it's not in any subdirectory).
Make sure that the Build Action for your image is set to resource, otherwise it won't work with the WPF Resource Finding System (which internally uses PACK-Uris: http://msdn.microsoft.com/en-us/library/aa970069(v=vs.110).aspx)
I use .NET 4.5 with VS 2013. If you have any further questions, please feel free to ask.
Update after Bill's comment:
That's a whole different thing when your resource resides within another assembly. The syntax for referencing the image should be like this:
<Image Source="/ClassLibraryForResources;component/Images/visual studio.png" />
where you do the following steps:
Begin with a slash "/"
Specify the name of the assembly that holds your resource (this can also be a strong assembly name)
Continue with ";component/"
End with the path of the image (or other resource)
(Please note that you have to omit the quotation marks).
The solution that I used is structured like this:
This should resemble what you have described. Again: it's all about the PACK URIs that WPF uses (see link above).
I have added Awesomium webcontrol in my WPF Page (Frame Navigation)
But its not loading any webcontent, but if i add the webcontrol in WPF Window, its working fine.
Please suggest me how to load a Awesomium webcontrol within WPF Page control
Below is the code which i am using in my application
Thanks in advance.
<Page x:Class="Project15A.SocialMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Project15A"
xmlns:my1="clr-namespace:Project15A.Controls"
xmlns:my2="http://schemas.awesomium.com/winfx"
MinHeight="300" MinWidth="500" Title="Project15A"
Loaded="Window1_Loaded">
<Grid Background="White">
<my2:WebControl HorizontalAlignment="Left" Margin="154,65,0,0"
Name="webControl1" VerticalAlignment="Top"
Source="http://www.google.com" />
</Grid>
</Page>
So I figured this one out. It is not a bug in Awesomium. (Though I think it should be on a quick start page.)
Awesomium supports two view modes. Offscreen and Windowed.
Offscreen is something that very manual. All input goes through you. (Why the default events don't still fire is kind of odd). I think this is the mode you will end up using if you want to interact with your HTML.
But if you want a normal imbedded browser window then you need to turn on the Window view mode.
Here is an example:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:awe="http://schemas.awesomium.com/winfx"
x:Class="WpfAndSpa.MainWindow">
<Grid>
<awe:WebControl x:Name="WebControl"
ViewType="Window" <--------------+
Source="http://google.com"/> |
</Grid> |
</Window> |
|
This is the key part -----------------------------------------+
I´m using the librariay Extended WPF Toolkit
https://wpftoolkit.codeplex.com/
Is it possible to resize a ChildWindow like a ordinary Window?
The documentation shows some properties that seem to be related, but they are not accessible via xaml. https://wpftoolkit.codeplex.com/wikipage?title=ChildWindow
This is the example that I´m trying:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:s="clr-namespace:System;assembly=mscorlib">
<xctk:WindowContainer>
<xctk:ChildWindow WindowBackground="Blue"
Left="75"
Top="50"
Width="275"
Height="125"
WindowState="Open" Canvas.Top="52">
<TextBlock Text="This is a Child Window" Padding="10"/>
</xctk:ChildWindow>
</xctk:WindowContainer>
</Window>
It appears as though the Resize functionality is only available in the Plus Edition of the software, the documentation can be found at the link below.
Based on the link you provided, it looks like you are using the same version as I am, which is the free one.
https://wpftoolkit.codeplex.com/wikipage?title=ChildWindow%20Plus
Kind of disappointing, we don't utilize the toolkit enough to warrant the cost.
I am trying to create a popup from my WPF application which shows a report viewer hosted in a WindowsFormsHost
however I am having problems with the following Xaml
<Page x:Class="FIS3.ReportViewer.ReportViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
Title="MapViewer">
<Grid>
<my:WindowsFormsHost>
</my:WindowsFormsHost>
<Label Name="exampleText" Content="this is the Report Viewer ..." />
</Grid>
I am getting a build error notifying me that
"The type 'my:WindowsFormsHost' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built"
have I made an error in my XAML
I have added WindowsFormsIntegration as a reference to my project.
Thanks for your help
Col
There is a second solution to this that people seem to have overlooked. I scratched my head on this one for a good 20 minutes. No solution, including this one, would work. Turns out the solution for me was to add:
WindowsFormsIntegration
to my references
after I realized that based on:
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx
that this uses the WindowsFormsIntegration.dll. It seemed to have been missing from my references.
Hope this helps!
According to the MSDN documentation, WindowsFormsHost is included in the default Xaml namespace ("http://schemas.microsoft.com/winfx/2006/xaml/presentation") - though you do need to reference WindowsFormsIntegration, as you have done. Have you tried referencing WindowsFormsHost with no namespace prefix?
<Page x:Class="FIS3.ReportViewer.ReportViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MapViewer">
<Grid>
<WindowsFormsHost>
<WindowsFormsHost>
<Label Name="exampleText" Content="this is the Report Viewer ..." />
</Grid>