How to create a simple tile in wpf? - wpf

How to create a simple tile in WPF, is there a native control? or it is absolutely necessary to install a package via nuget?
I saw that there was control: Tile Control but I can not find it in the toolbox
Thanks in advance

There is no built-in Tile control available in WPF.
You will have to create a custom yourself or use a third-party control.
There are free open-source options available, like for example the mahapps.metro Tile control: http://mahapps.com/controls/tile.html. It does of course require you to install mahapps.metro (preferably using NuGet) though: http://mahapps.com/guides/quick-start.html

add these namespace in a page or window xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro".By this,we can use tile in mahapps
<mah:Tile ToolTip="Tile" Width="90" Height="50" Click="GetTileDetails" HorizontalAlignment="Center" HorizontalContentAlignment="Center" FontFamily="Times New Roman" FontSize="22" >
<TextBlock Text="Text" ></TextBlock></mah:Tile>

Related

Using ReactiveUI V8+ RoutedViewHost in WPF

I am trying to upgrade my application template up to V8+. Previously working xaml seems to be broken. .NET Framework 4.7.2, ReactiveUI 8.3.1
<!--Client Area-->
<reactiveUi:RoutedViewHost x:Name="ViewHost"
Margin="3,9.667,3.333,3"
HorizontalAlignment="stretch"
VerticalAlignment="Stretch"
Grid.Row="1">
<reactiveUi:RoutedViewHost.DefaultContent>
<WrapPanel>
</WrapPanel>
</reactiveUi:RoutedViewHost.DefaultContent>
</reactiveUi:RoutedViewHost>
Gives a design-time warning:
"Don't know how to detect when Reactiveui.RoutedViewHost is activated/deactivated, you may need to implement IActivationFoViewFetcher". Am I missing a package or has there been a fundamental change in RoutedViewHost behavior?
There is a new nuget package called reactiveui.wpf that you need to include.
This will register a IActivationForViewFetcher.

Why does my app ignore certain xaml code on Windows 7?

I'm creating a WPF C# .Net App with the Aero theme which is supposed to run on Win7 as well as Win10.
On Win10 everything works as it's supposed to, however on Win7 the GUI looks vastly different.
In particular, my MenuItems simply seem to ignore certain settings such as VerticalContentAlignmentand BorderThickness.
Pics:
Win7 vs
Win10
How do I fix this?
(Some Code:)
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
<MenuItem Header="Intranet"
Grid.Column="2"
x:Name="Menu_Intranet"
ToolTip="Intranet"
BorderBrush="white"
BorderThickness="5"
VerticalAlignment="Stretch"
Click="Menu_1_Click"
ToolTipService.ShowOnDisabled="true"
VerticalContentAlignment="Center"/>
Thanks in advance!
I edited the MenuItemControlTemplate (right click on the control you want to edit in the designer -> edit template) and applied it to the MenuItems via Template="{DynamicResource MyMenuItemControlTemplate}".
I guess this leaves no room for the OS/Theme to apply its own settings.

WPF Font Ms Gothic in .net 4.0 doesn't look the same in .net 3.0

I moved from .Net Framework 3.0 to 4.0 and the Japanese (and English as well) text became clear and lost weight
I want it back as it was in .Net 3
photo: new = .Net 4, old = .Net 3
I've followed this blog trying to fix it but no success yet
tried the following with different combinations:
<TextBlock Text="{Binding Text}" FontSize="16" Foreground="White" FontFamily="MS Gothic" RenderOptions.ClearTypeHint="Enabled" />
<TextBlock Text="{Binding Text}" FontSize="16" Foreground="White" FontFamily="MS Gothic" TextOptions.TextFormattingMode="Ideal"/>
<TextBlock Text="{Binding Text}" FontSize="16" Foreground="White" FontFamily="MS Gothic" TextOptions.TextRenderingMode="ClearType"/>
Any suggestions how to solve this?
It is not a solution, but on Microsoft's forum, there was an answer that the thicker font display is "caused by internal font optimization of WPF rendering system" for two fonts, MS UI Gothic and Bold MS UI Gothic.
As there are no solutions suggested there, I assume that you can not avoid that optimization. If MS UI Gothic are not MUST for what you are making, you may use Meiryo or other Japanese fonts to work around it.
This is also not a solution but I had a similar issue in that I wanted to use a particular font which was not available on Windows XP, but was in Vista and Win 7. I found an open source compatible font and included it as a resource in my application. This way I ensured that the application font looked the same across all versions of Windows.
You may be able to find a font that you could include in your application.

Image in ComboBox only visible in designer

Here's the situation:
I have a combobox within a button,, In expression blend when I add image to combo box item with the cod below, there's no problem apparently, image and textblock are showing well but as I run the proj.((F5)) there'e no sign of image, What I'm doing Wrong???
here's the code I use to add the image:
<ComboBoxItem Background="LightCoral" Foreground="Red"
FontFamily="Verdana" FontSize="12" FontWeight="Bold">
<CheckBox Name="CoffieCheckBox">
<StackPanel Orientation="Horizontal">
<Image Source="coffie.jpg" Height="30"></Image>
<TextBlock Text="Coffie"></TextBlock>
</StackPanel>
</CheckBox>
Any help Is much appreciated...
One likely problem might be that the image file is in your project folder without being copied to the build folder; /bin/Release for example. The application then will not find the file anymore. You can either ensure that the image is being copied when the application is compiled (that alone may not work actually as unqualified URIs make the parser look for resources as far as i know, the designer however does not seem to care) or you can embed the image as a resource. I do not know how to change compile settings in Blend however as i only use Visual Studio...
I had a similar problem showing images (used Uri strings) in a listview in a Silverlight application. They appeared properly in Expression Blend, but were not visible when I started it from Visual studio.
I kept my images in a folder called Images in my project, by setting the "Build action" for my image properties into "Content" fixed the problem. Now they show up when running the application. Hope it helps!

Windows Forms User Controls in WPF app

Could someone post a link to simple tutorial, which describe how to use User Controls, created in Win Forms in WPF aplication's?
Thank's a lot.
In a nutshell:
1.Add a reference in your WPF project
to System.Windows.Forms and
WindowsFormsIntegration
2.Add the namespace in your XAML:
xmlns:WinForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
3.Use the WindowsFormsHost tag to surround any WinForms controls you use:
<Grid>
<WindowsFormsHost>
<WinForms:DataGrid />
</WindowsFormsHost>
</Grid>
4.Profit!

Resources