My Universal Windows Platform Application crashs when I click menu items - c#

I made the Icons of my menu Items using FontIcon and I write 'Segoe Fluent Icons' In the FontFamily section and use It. But when I click on my menu Items, my app crashes. I downloaded the 'Segoe Fluent Icons' font package from Microsoft's site and tried It, but when I restart my PC, the same problem happens again.
My Menu Items Code:
<muxc:MenuBar>
<muxc:MenuBarItem Title="Example">
<MenuFlyoutItem Text="Item1">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xF6FA" FontFamily="Segoe Fluent Icons"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</muxc:MenuBarItem>
</muxc:MenuBar>

I tried your code, it seems that you are missing a semicolon for the value of Glyph property. After adding it, the code could run correctly and the Icon will show.
Code here:
<MenuFlyoutItem.Icon>
<FontIcon Glyph="" FontFamily="Segoe Fluent Icons"/>
</MenuFlyoutItem.Icon>
Result:

Related

How to make the sidebar transition?

I have a simple splitview that has a rectangle of width 4px that indicates the selected item in the spiltview.
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Top"
Width="4" Height="48" Margin="1,0"
Fill="{ThemeResource SystemAccentColor}" Grid.Row="2"
Visibility="{x:Bind btnHome.IsChecked, Mode=OneWay}"/>
Right now I've multiple rectangles turned on/off depending whether the checkbox is selected or not! But instead, I want a single rectangle in my code that should transition from the place where it previously was to place where the user has clicked.
Simplest for you would be using the new NavigationView if your minimum version is set to Fall Creators Update or use the HamburgerMenu control from UWP Community Toolkit (note that it's updated to use style very similar to yours, the docs aren't just updated with current screenshots). You can download the UWP Community Toolkit Sample App from Windows Store if you want to see how it currently looks.
If you want to use your custom solution, you should create a custom style or rather edit an existing style of the control you're using as hamburger menu items. Default styles are available for example here.

Add own glyph to uwp project

I'm working on my Pivot header (UWP-Project) and wanted to add a custom glyph:
From here:
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" RenderTransformOrigin="0.5,0.5">
Now I want to use custom (or other Glyphs) for example from Fontawesome.
Here the steps:
Added fontawesome.ttf to my project
Changed FontFamily="Segoe.." to FontFamily="../Resources/#FontAwesome"
Changed Glyph to Glyph=""
But instead of the Glyph I'm getting just a empty rectangle. What did I do wrong? Is it maybe not possible in UWP-Projects? This solution here did not help me.
Changed FontFamily="Segoe.." to FontFamily="../Resources/#FontAwesome"
This is where the 2nd part is wrong. What you need is FontFamily="ms-appx:///Path/To/Font/Font.ttf#FontName" - you only have the "#FontName" part.

Windows 8.1 control that opens the appbar?

In the Internet Explorer App, there is a little bar on the bottom that is used to open the app/command bar.
It also shows up in the mail app:
I have just a simple CommandBar at the moment, which is completely hidden until the user right-clicks or swipes from the bottom:
<Page.BottomAppBar>
<CommandBar>
<AppBarButton x:Name="Button_Save" Icon="Save" Label="Save" Click="Button_Save_Click"/>
<CommandBar.SecondaryCommands>
<AppBarButton Icon="Crop" Label="Canvas Size"></AppBarButton>
<AppBarButton Label="Grid Size" Icon="ViewAll"></AppBarButton>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>
Rather than just creating my own control, it would be nice if there was one that already existed for me to use. I don't know the name of this "Command bar grip" so I cant seem to find much information on it. If it does exist, what's the name of it? And if not, any ideas on how to make one? I would probably just use a rectangle and add the little "..." on the side.
I have seen it in some apps apart from Microsoft, but there appears to be no information on the control.
There isn't a standard control for this. The in-box AppBar on Windows 8.1 either hides or shows and doesn't have an intermediate hint mode.
You can implement it yourself by creating a panel at the bottom of the page animating its position so it is either fully visible or shows only the ellipses. This can be done fairly easily by setting visual states for the visible and hinting states and switching to the visible state when the control receives focus or pointer input. As Robert Hartley suggests, the ellipses can be found in the Segoe UI Symbol font at 0xE10C ("More")
<TextBlock Text="" HorizontalAlignment="Right" VerticalAlignment="Top" FontFamily="Segoe UI Symbol"/>
I haven't used it, but Dave Smits provided a sample AppBarHint control which implements a hinting app bar for Windows. You might want to take a look at how he did that too.

Add icon to button with Visual Studio

I have a simple question. I want to add an icon to a C# WPF Button control. I do not want to have to write C# code, or edit XAML to do this.
However, when I click on the button in the Designer, there is no option under properties to set an image. How do you do this through the Visual Studio GUI?
The easiest/best way to do this is to add an Image control as the Content of the Button.
The property window is somewhat limited in what it can do, and only supports text for that property. This does include bindings, so you could use an Image StaticResource. I couldn't find an easy way to create one from the property designer either though.
So basically, you are stuck with editing XAML. Either with a direct Content property or by creating an element in Resources Its not that bad! Just write:
<Button>
<Button.Content>
<Image ImageSource="..."/>
</Button.Content>
</Button>
Now of course, you could create a custom button that exposed that property via the designer, but thats even more XAML. Its WPF, you are going to have to write XAML, so learning how should be a priority.
Visual Studio 2015:
create a button.
create an image.
set the source of the image to the right file of your resources (e.g. a .png file that you included to your project)
drag the image over the button.
A text shows that asks you to press ALT to replace the text of the button with the image.
I currently don't know how to get both, image and text, for a button.
in XAML, it looks like this:
<Button x:Name="button12" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75">
<Image x:Name="image" HorizontalAlignment="Left" Height="24" VerticalAlignment="Top" Width="24" Source="gfx/new.png"/>
</Button>
you could install FontAwesome on your Computer
Goto http://fontawesome.io and download. Open the downloaded ZIP file and inside the font folder there should be .otf file, Install that!
and in the content of the button you could simply type the desired icons code!
For eg:
if you want your button to look like this
then install FontAwesome Font
and in your button tag type Content="" FontFamily="FontAwesome"
More codes can be found here http://fontawesome.io/cheatsheet/

silverlight toolkit listpicker wp7 missing icons

I'm having a problem with the listpicker (SelectionMode="Multiple"!!!). When i go to fullmode it doesnt show "done", "cancel" icons like if the images were not in my project.
On full screen mode i only have this xaml code
<DataTemplate x:Key="listPickerFullModeItemTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontSize="30" Height="40" FontFamily="Segoe WP"/>
</StackPanel>
</DataTemplate>
<toolkit:ListPicker Header="Floral" SelectionMode="Multiple" FullModeHeader="Floral" CacheMode="BitmapCache" x:Name="floralListPicker" Margin="0,0,12,0" ItemTemplate="{StaticResource listPickerItemTemplate}" FullModeItemTemplate="{StaticResource listPickerFullModeItemTemplate}"/>
Code is ok, everything works fine but the icons doesn't show, actually it shows as the default app bar missing icon image. I copied the images from toolkit sample but no go.
anyone know whats wrong?
anyway to force icons on template?
thanks.
Do you need to set the Build Action of the icons to "Content" in their properties window?
I found out the solution by exploring the sample solution of the toolkit.
If you don't use a special page for the fullmode selection, you need to include the following images to your project:
Create one subfolder named Toolkit.Content (not ToolKit/Content).
Then, include the files named as this : ApplicationBar.Cancel.png and ApplicationBar.Check.png.
Mark them to be generated as content.
That's all! Your icons should now been displayed.
Hope this helps you !

Categories