Font in silverlight for Windows Phone 7 - silverlight

I want to use a font for textbox in my silverlight application for Windows Phone 7. The font isn't contained in the default font list.
Here is xaml code for applying the font to a textbox:
<TextBlock Grid.Row="1" Height="95" HorizontalAlignment="Left" Margin="527,78,0,0" Name="textBox" Text="0" VerticalAlignment="Top" FontSize="72" Width="70" FontFamily="/MyAppNamespace;component/Fonts/Fonts.zip#Papyrus"/>
The font is included in the folder Fonts.
The XAML view window for this page show exact font style that I want. But when I tried to deploy the app to my Samsung Omnia 7 the font used is still Segoe WP (the default font for text box).
So what's the problem here?

You need to include the font in your application. The easiest way to do this is to go into Blend, select your TextBlock element, go to Text properties section, and click the Embed checkbox. Note that if you're using a separate build server, this will require you to have the Blend SDK installed on that system. (For font embedding, Blend uses a custom build target. I believe it's the SDK adds this build target to the target system.)
The reason you're seeing Segoe WP is because your specified font is not found, so the runtime is falling back to a font it knows. You haven't specified any fallback fonts, so it's using the default of Segoe WP.

Related

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.

Using font icons in WP8.1 Silverlight ApplicationBar

I'm trying to figure out why I can't use the glyphicons that are available to WP8 XAML apps in my Silverlight 8.1 Application.
As you can see from the fragment below, I have to specify an image to use as the icon compared to the ease of using one of the glyph icons.
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
Does anyone know how I can simply use the icons without needing to go through the extra work of creating images?
In WP8.1 Silverlight you need to use an image. The symbol enumeration with those glyphicons are only available for Windows (Phone) Store apps only, see the documentation:
Minimum supported Phone: Windows Phone 8.1 [Windows Runtime apps only]

Silverlight AutoSize and Visual Studio 2010 for Windows Phone

I have designer using Blend to desing windows phone pages. It has d:DesignHeight and d:DesignWidth set.
I use Visual Studio 2010 Express for Windows Phone. Now if I open any .xaml file in DesignMode, it reset the DesignHeight and Width. It is really annoying as I have to manually change back those values before checking in my changes to sourceControl.
Saw this one WPF UserControl Design Time Size
but to do it in every page would be a stupidity for me.
Hope there is a switch in VS, which I am not aware of.
Any ideas please?
Update
I have the following:
SupportedOrientations="Landscape" Orientation="Landscape"
shell:SystemTray.IsVisible="True" d:DesignHeight="800" d:DesignWidth="480">
When I view in Design Mode it changes to
d:DesignHeight="480" d:DesignWidth="782">
The Windows Phone has a fixed Page size (480x800 pixels)
When you design a Page the designer determines the appropriate size in the designer by looking at the orientation of the page and the visibility of the SystemTray:
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="False">
My guess is that because you can only design Pages that are full screen, the designer keeps replacing custom set values for the height and width.
When creating a User Control (not a Page!) you are free to change the Height and Width any way you want.

Adding an external font to WP7 app

I want my WP7 app controls and to have a certain font which is not in Visual studio font selection, how can I add the font to the font list of Visual studio or directly into my controls?
This can be easily done using Expression Blend.
In your project, select a TextBlock and go to the Properties panel, under Text section, there is a Font Manager button (see below), click it and then you can select the font you want in a popup window.
Expression Blend will automatically create a Fonts folder and put all the embedded fonts in there, really easy to use. :)
Here's a post showing how to embed fonts in a silverlight project (see the section 'Custom Fonts'):
http://blogs.silverlight.net/blogs/msnow/archive/2009/09/09/97060.aspx
I haven't tested this in a windows phone project but it should work.

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!

Resources