Some Extended Unicode Characters (e.g., Zodiac Symbols) Displaying Differently between UWP and WPF - wpf

Certain extended Unicode characters, among which are the Zodiac symbols, are displaying differently in WPF TextBlocks vs. UWP TextBlocks. In UWP, as well as web browsers (for example, ♑), Toast messages, etc., display the characters with a purple background and white foreground. In WPF, the same characters are displayed with the control's background color and a black foreground. Ideally, the characters in WPF apps should be displayed consistently with the way they are displayed in other apps.
The following are the results of two test apps, one created as UWP and the other created as WPF. No changes were made to any of the other files (App.xaml, etc.), apart from the addition of the TextBlock control as follows:
UWP MainPage.xaml:
<Page x:Class="UwpApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UwpApp1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="150" Width="150">
<Grid>
<TextBlock Text="♑" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" FontFamily="Segoe UI" FontSize="48"/>
</Grid>
</Page>
UWP application screen:
WPF MainWindow.xaml:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="150">
<Grid>
<TextBlock Text="♑" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" FontFamily="Segoe UI" FontSize="48"/>
</Grid>
</Window>
WPF application screen:
Is anyone aware of an application setting or any other change that can be done to the WPF application so it will display these types of special characters consistently with other applications?

Related

How to make the WebView2 fit and full the Window (adaptive size effect or full - screen)?

I tried to set HorizontalAlignment="Stretch" & VerticalAlignment="Stretch"
but it was not work.
<Window
x:Class="Y.Shen12DP.PLCT.WebWidow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Y.Shen12DP.PLCT"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
Title="WebWidow"
Width="800"
Height="450"
mc:Ignorable="d">
<Grid>
<wv2:WebView2
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Source="https://www.microsoft.com/" />
</Grid>
</Window>
enter image description here
Could you tell me how to do it (adaptive size effect or full - screen)?
The code you have will ensure the WebView2 fills the WPF Window. To make it full screen you need to make the WPF Window full screen which is described elsewhere on StackOverflow: Full screen in WPF application. Once the WPF Window is full screen the WebView2 should be full screen as well.

Combo Box touch events not firing in Windows 10 VS2017

Created a test application with a wpf combo box.
Using touch select an item from Combo box,after selecting the item combo box close after a flickering.
This flickering is not observed using mouse clicks.
Following are the specification for Application:
1.Made AllowsTransparency="True" for windows
2.Unchecked "Enable press and hold for right clicking" in Pen and Touch setting
System Specification:
1.Windows 10
2.VS 2017 and .Net framework 4.7
Some search results shows it is a common issue in Windows 10 that when windows is transparent touch events are not firing.
On Windows 10 (1803), all applications lost touch or stylus if a WPF transparent window covers on them
Workaround mentioned in it is not working in our case.(ResizeMode="NoResize") .
Is there any other workaround for this?
Following is my xaml code:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d" WindowState="Maximized" WindowStyle="None"
Title="MainWindow" Height="800" Width="800" Background="Transparent" AllowsTransparency="True">
<Grid>
<ComboBox Name="cb" Height="50" Width="50">
<ComboBoxItem>A</ComboBoxItem>
<ComboBoxItem>B</ComboBoxItem>
<ComboBoxItem>C</ComboBoxItem>
<ComboBoxItem>D</ComboBoxItem>
<ComboBoxItem>E</ComboBoxItem>
<ComboBoxItem>F</ComboBoxItem>
<ComboBoxItem>G</ComboBoxItem>
</ComboBox>
</Grid>
</Window>

PlaceholderText is not accessible XAML

I am new to XAML and WPF.
I am trying to add a placeholder to my textbox but I got this error: "The property 'PlaceholderText' was not found in type 'TextBox'" and "The member "PlaceholderText" is not recognized or is not accessible".
When I tried to type PlaceholderText, it didn't even show up in the auto-complete drop down list. "Header" has the problem.
I am using VS 2015 community and .NET Framework 4.5.2
Below is my code which I got it from https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.textbox#Examples
<Window x:Class="QuickGarbageSort.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyTestApp"
mc:Ignorable="d"
Title="MyTestApp" Height="550" Width="800">
<StackPanel>
<TextBlock Text="What's your name?"/>
<StackPanel Orientation="Horizontal" Margin="0,20,0,20">
<TextBox x:Name="nameInput"
Header="Enter your name:" PlaceholderText="Name"
Width="300" HorizontalAlignment="Left"/>
<Button Content="Hello button" Click="Button_Click"/>
</StackPanel>
<TextBlock x:Name="greetingOutput"/>
</StackPanel>
The documentation you got the code from is a documentation for Windows.UI.Xaml.Controls.TextBox, this is the textbox control used in Universal Windows Applications. This has a property called PlaceholderText
The WPF one is System.Windows.Controls.TextBox, this is different and doesn't have a PlaceholderText property. In order to have something like the UWP placeholder text in WPF, you have to implement it yourself or use a third party library which offers a control with this functionality.

Images not appearing on buttons when user control is in referenced assembly

I have a main WPF application which references a WPF User Control Library that I created. In the library, I have one user control and an images folder (images used by user control). Here is part of the XAML that I have in the user control:
<UserControl x:Class="Alstom.UserControls.MainToolbar"
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"
xmlns:local="clr-namespace:Alstom.UserControls"
mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="3440">
<UserControl.Resources>
<Image x:Key="Subway" Source="/images/MainToolbar/Subway.png"/>
<Image x:Key="Globe" Source="/images/MainToolbar/Globe.png"/>
<Image x:Key="Gavel" Source="/images/MainToolbar/Gavel.png"/>
<Image x:Key="Clipboard" Source="/images/MainToolbar/Clipboard.png"/>
<Image x:Key="EllipsisVertical" Source="/images/MainToolbar/EllipsisVertical.png"/>
<Image x:Key="Check" Source="/images/MainToolbar/Check.png"/>
<Image x:Key="Bell" Source="/images/MainToolbar/Bell.png"/>
The user control has buttons which I wrote like the following (note that I defined the Content property as StaticResource:
<Button x:Name="button" Grid.Row="1" Grid.Column="0" Content="{StaticResource Subway}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="48" Height="48"/>
When I double click the user control, in the designer, I see the images on the buttons.
But I created a main WPF application in my solution which references the external assembly like so:
<Window x:Class="MainToolBar.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:myMainToolbar="clr-namespace:Alstom.UserControls;assembly=Alstom.UserControls"
mc:Ignorable="d"
Title="MainWindow" Height="auto" Width="3440" ScrollViewer.VerticalScrollBarVisibility="Visible">
<Grid>
<myMainToolbar:MainToolbar HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid>
When I double-click the MainWindow.xaml, I don't see the images on the button in the designer, nor when I run it.
What do I need to do to show the images at runtime? In the user control project, the images have a Build Action = Resource. But I tried to change one of them to Embedded Resource, and it still did not work.
What am I doing wrong?
Try to set the build action of the images to Resource and use a pack URI:
<Image x:Key="Subway" Source="pack://application:,,,/YourAssemblyName;component/images/MainToolbar/Subway.png"/>
Don't forget to change "YourAssemblyName" to the actual name of your assembly/WPF User Control Library project.
Pack URIs in WPF: https://msdn.microsoft.com/en-us/library/aa970069(v=vs.110).aspx

Don't understand why the user control we've written doesn't show up in a ModernWindow but does in a window

We're working on a WPF app, using the ModernUI for WPF. And we're also using MVVM Light. We've written some user controls which we intend to bring up in separate windows. Each of the windows are ModernUI's ModernWindow. Whenever we try to bring them up, nothing is shown in the ModernWindow. Out of frustration I thought I'd try doing the same thing in a plain old WPF window. Works perfectly each time. I don't know why it works in a regular WPF window but doesn't work in a ModernWindow. What is wrong???
Here's the XAML for the plain old window:
<Window x:Class="CoreFramework.BozoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:view="clr-namespace:CoreFramework.View"
xmlns:local="clr-namespace:CoreFramework"
mc:Ignorable="d"
Title="Bozo Window" Height="300" Width="300">
<ContentControl Content="{Binding ProductList, Source={StaticResource Locator}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
And here's the XAML for the ModernWindow:
<mui:ModernWindow x:Class="CoreFramework.DataViewWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:vm="clr-namespace:CoreFramework.ViewModel"
xmlns:view="clr-namespace:CoreFramework.View"
xmlns:content="clr-namespace:CoreFramework"
Title="BOTS"
ShowInTaskbar="True"
Closing="ModernWindow_Closing">
<ContentControl Content="{Binding Path=ProductList, Source={StaticResource Locator}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
One approach you could use is adding Menu links which is built into the Modern UI framework:
<mui:ModernWindow x:Class="ExampleApp.ExampleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
Title="Scrum Manager" IsTitleVisible="True" ContentSource="/Views/DefaultUserControl.xaml"
x:Name="mainWindow" MenuLinkGroups="{Binding Groups}"
WindowStartupLocation="CenterScreen" WindowState="Maximized">
<i:Interaction.Triggers>
</i:Interaction.Triggers>
<mui:ModernWindow.TitleLinks>
<mui:Link DisplayName="settings" Source="/Views/SettingsWindow.xaml" />
<mui:Link DisplayName="Sign out" Source="/Infrastructure/Logout.xaml" />
</mui:ModernWindow.TitleLinks>
When a link is clicked, it opens up the 'Source' which would be UserControl xaml files.
See Github for more details:
https://github.com/firstfloorsoftware/mui

Resources