I'd like to use strikethrough in a UWP app. For example: '10% off £100 £90.' The advice seems to be to use TextDecorations, which in 2012 was still not available (link). Please can you tell me if it's possible to use strikethrough in a TextBlock now?
According to the offical documentation, strikethrough is an available TextDecoration.
An XAML-Example:
<!-- Use the default font values for the strikethrough text decoration. -->
<TextBlock
TextDecorations="Strikethrough"
FontSize="36" >
The quick red fox
</TextBlock>
I tested the example by myself in an UWP-Application and had no problems.
How Rob mentioned:
It is available since v10.0.15063.0.
Related
I am using the WinUI technology.
I would like to display a HyperlinkButton in my XAML.
The problem is that the HyperlinkButton is not displayed underlined.
But according to this documentation this should be the case / the default behavior: MSDN - HyperlinkButton Class
Here is what I have:
<HyperlinkButton Content="Example" Click="HyperlinkButton_Click" />
Neither I have any style that would affect how the button is displayed nor did I change a template.
What am I missing?
Thank you.
UPDATE
The problem exists in version 1.0.1 (march 2022) of Windows App SDK as well as in version 1.0.0 (november 2021), see windows-app-sdk/downloads
The template of the HyperlinkButton has changed in later versions of the Windows App SDK (1.0.0+) but apparently the documentation hasn't been updated.
You should still be able to use a Hyperlink element to get an underlined link though:
<TextBlock>
<Hyperlink Click="Hyperlink_Click">Example</Hyperlink>
</TextBlock>
HyperlinkButton missing underlined text is almost confirmed a bug.
As a workaround to add underline on the button text string, you can try the following way to display something with TextDecorations property as "Underline".
<HyperlinkButton Click="HyperlinkButton_Click">
<TextBlock Text="www.microsoft.com" TextDecorations="Underline" />
</HyperlinkButton>
Edit:
Finally, according to the issue,
The documentation needs updating to reflect the updated design for
HyperlinkButton first introduced in WinUI 2.6, see the WinUI Figma
toolkit for more info.
I'm setting up a stacking column chart in XAML using Syncfusion for Xamarin in Visual Studio 2017. I've tried adding custom text according to the example here, but I run into an exception when the tooltip is activated. Here's the code I'm using:
<chart:SfChart.Series>
<chart:StackingColumnSeries EnableTooltip="True"
Width="0.5"
ItemsSource="{Binding TankLevels}"
XBindingPath="Name" YBindingPath="Level1">
<chart:StackingColumnSeries.TooltipTemplate>
<DataTemplate>
<StackLayout>
<Label Text="test"></Label>
</StackLayout>
</DataTemplate>
</chart:StackingColumnSeries.TooltipTemplate>
<chart:BarSeries.ColorModel>
<chart:ChartColorModel Palette="Custom" CustomBrushes="{Binding WaterColor}">
</chart:ChartColorModel>
</chart:BarSeries.ColorModel>
</chart:StackingColumnSeries>
I have analyzed your code snippet and prepared a sample based on it, and the sample can be downloaded from the link below.
Sample: 215585
I am afraid I was not able to reproduce the reported issue, it is working fine. Can you please provide more information like a stack trace on the exception?
Thanks,
Michael
Note: I work for Syncfusion
The issue was that I was using an outdated version of Syncfusion's Xamarin Controls. I didn't have any more issues after updating to the newest version.
Since Windows 10 has .NET introduced the property FontIcon.Glyph. If you add code below to your xaml page if gives me next char Σ.
<FontIcon FontFamily="Candara" Glyph="Σ"/>
So I was thinking can you add an other icon font like Font Awesome or Icomoon info your project?
I've download a font, added into my solution and I use this code:
<FontIcon FontFamily="ms-appx:/Fonts/FontAwesome.otf#FontAwesome" Glyph="" Foreground="Black"/>
what results into this:
Is there a simple way to display a degrees symbol (as in Fahrenheit) in XAML? Ive been able to find solutions in HTML, Android and iPhone but nothing in xaml.
You can use the same code/number used in HTML
This shows Shows "55º"
<TextBlock Text="55º"/>
Is this: " ° " the symbol you're looking for? I recommend just copying/pasting it into your XAML code and it should display properly.
The correct HTML code is 176, according to this link. The code 186 is masculine ordinal indicator. So the correct answer would be
<TextBlock Text="°F"/>
This will show "°F".
I'm making a Windows Phone 7 application and I'm a bit confused with dark/light themes.
With a panorama, you very often set a background image. The issue is it's very hard to make a picture which is right for both dark and light themes. How are we supposed to proceed?
Is there a way to force a dark/light theme for a panorama? This will avoid making theme-specific panorama background pictures. Then how do I do? I found xaml files in C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Design. If this is a right way to proceed, how can I import them for my panorama?
Or if there's no way (or if it's wrong) to force a dark/light theme: how to write conditional XAML to set correct resources? Now I have the following XAML (default.xaml) which is fine with the dark theme:
<ImageBrush x:Key="PageBackground" ImageSource="Resources/PageBackground.png" Stretch="None" />
<ImageBrush x:Key="PanoramaBackground" ImageSource="Resources/PanoramaBackground.png" Stretch="None" />
But when I use a light theme, black controls and black texts are hard to read with my dark background pictures. So I made different pictures that I can use this way:
<ImageBrush x:Key="PageBackground" ImageSource="Resources/PageBackgroundLight.png" Stretch="None" />
<ImageBrush x:Key="PanoramaBackground" ImageSource="Resources/PanoramaBackgroundLight.png" Stretch="None" />
Now my issue is to make XAML conditional to declare the right thing depending on the current theme.
I found no relevant way on the Internet. I would prefer not to use code or code-behind for that because I believe XAML is able to do this (I just don't know how).
EDIT: Code snippet to load a xaml file as ResourceDictionary
string xaml = null;
StreamResourceInfo xamlInfo = Application.GetResourceStream(new Uri("light.xaml", UriKind.Relative));
using (StreamReader sr = new StreamReader(xamlInfo.Stream))
xaml = sr.ReadToEnd();
dic = (ResourceDictionary)XamlReader.Load(xaml);
this.Resources.MergedDictionaries.Add(dic);
To force a dark or white theme you can indeed use the styles defined in the folder you pointed out. Copy and Paste the rules you need to your App.xaml (just PhoneForegroundColor, PhoneBackgroundColor and the related Brushes would be a good start).
It's probably better though to stay "theme-aware" and load a different image for light and dark themes. Here is an article explaining how to do this: http://blog.jayway.com/2010/12/16/theme-aware-panorama-background-in-windows-phone-7/
There is another possibility I've found: You can use the Coding4Fun Toolkit Converter according to these instructions. However, I'm unable to use correctly use them.
Another possibiliy is to use an OpacityMask. But this only works for black/white images :/
Yousef's solution looks interesting. but it takes too much time to load. The image will be changed round about 1s after the app started. I've tested this on a Nokia 820. I've moved the call for setting the DataContext in a Loaded Event, which was called much later. Now the call takes place in the constructor, so the image will be already set when the application displays it. However, it still adds more loading time :( Any suggestions on how to improve this?