Right align (Help) button on WPF ribbon - c#

I'm attempting to add a Help button on the right side of the tabs in my WPF Ribbon app. I'm using the "WPF Ribbon Application" template is Visual Studio 2010, by the way. This is what I have so far:
<ribbon:Ribbon x:Name="Ribbon">
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Images\SmallIcon.png">
<ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
ImageSource="Images\LargeIcon.png"/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
</ribbon:RibbonTab>
<ribbon:RibbonButton x:Name="HelpButton"
SmallImageSource="Images\help.ico">
</ribbon:RibbonButton>
</ribbon:Ribbon>
This results in a left-aligned help button:
However, I want a right-aligned help button like one sees in MS Word 2010:
I've seen a suggestion to just adjust the margin on the button. While this does move the button to the right, it doesn't follow the edge of the window when the window is resized. Likewise, there's a similar question on SO to mine, but if you follow the answer, they're talking about ribbon groups, not buttons adjacent to the ribbon tabs.

Don't add the help button as a simple RibbonButton, use a HelpPaneContent element instead.
Don't do this :
<ribbon:RibbonButton x:Name="HelpButton"
SmallImageSource="Images\help.ico">
</ribbon:RibbonButton>
Do this instead :
<ribbon:Ribbon.HelpPaneContent>
<ribbon:RibbonButton x:Name="HelpButton" SmallImageSource="Images\help.ico"/>
</ribbon:Ribbon.HelpPaneContent>

Related

Fluent.Ribbon buttons

I'm somewhat new to WPF and .NET in general. I am using the Fluent.Ribbon library to create a ribbon for my application. I am also using the FontAwesome.Wpf library to draw icons on buttons and the like.
I am having trouble getting these to work nicely together, and I think it is due to how Fluent.Ribbon's button works.
If I write:
<Fluent:Button fa:Awesome.Content="Plus"
TextElement.FontFamily="pack://application:,,,/FontAwesome.WPF;component/#FontAwesome"
/>
I get "nothing" -- a blank button is "drawn." If I change it to using the standard WPF Button control, I get a button in the right place, using the right icon, but the style does not fit in with Fluent.Ribbon.
I want to just draw my font awesome icon in a nicely styled ribbon button. What should I do?
This is a little late but maybe interesting for others.
<Fluent:Button Size="Small" >
<Fluent:Button.Icon>
<fa:ImageAwesome Margin="0" Icon="Info" />
</Fluent:Button.Icon>
</Fluent:Button>
Setting the margin Property is only required when using the Icon in ToolBarItems.

How to customize splitview in Windows 10?

I am currently working on a Splitview Control which contains some menu options in SplitView Pane and a Grid in SplitView Content section. When the split view pane is opened its content gets hidden. Is it possible to move that slightly left like the following screenshot?
My basic split view implementation is
<SplitView x:Name="OptionsSplitView" OpenPaneLength="200" PanePlacement="Right"
DisplayMode="Overlay">
<SplitView.Pane>
<ListView x:Name="OptionsList"
Margin="10,10,0,0"
Grid.Row="1"
VerticalAlignment="Center"
ItemContainerStyle="{StaticResource GenericListViewContainerStyle}"
ItemTemplate="{StaticResource OptionsListItemTemplate}"
SelectionChanged="OptionsList_SelectionChanged">
</ListView>
</SplitView.Pane>
<SplitView.Content>
<Grid/>
</SplitView.Content>
</SplitView>
Please suggest is it possible to customize split view as per screenshot?
Bingo,
You can achieve it by just setting Right Margin of content whenever Pane Open or close.
Do refer Below link to get pane open & close event.
(Windows 10 UWP) SplitView.PaneClosed event is available but not for PaneOpened
Change your Splitview DisplayMode option to CompactInline or CompactOverlay as per your requirement

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/

KeyTip not working in Microsoft Ribbon

The 'KeyTip' is not working properly using the RibbonControlsLibrary (3.5.41019.1). I create a simple RibbonWindow:
Add a couple of tabs
Add some controls like a button
Set properties such as labels and headers
Set the KeyTip properties on the tabs
I test the KeyTip in desgin mode (VS2010) and everything works as expected. But when I build the project as a windows application the following occur:
ALT+KeyTip only shows the keytips, no focus is changing. The expected behaviour would be a change of tab...
I tried to create a clean WpfRibbonProject and did the same thing and then it works for some reason. The none working project is a mixture of Forms and WPF and a form is displayed before the WPF window. Could this be the problem? I cannon see why this would be a problem?
Source code:
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home" KeyTip="H">
<ribbon:RibbonGroup x:Name="Group1"
Header="Group1">
<ribbon:RibbonButton Label="Hej" KeyTip="T" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
<ribbon:RibbonTab Header="Tab1">
<ribbon:RibbonGroup Header="Min grupp">
<ribbon:RibbonButton Label="Test" />
<ribbon:RibbonSplitButton Label="Testen">
<ribbon:RibbonMenuItem Header="Jaha" />
</ribbon:RibbonSplitButton>
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
<ribbon:RibbonTab Header="Tab2" KeyTip="2" />
<ribbon:RibbonTab Header="Tab3" KeyTip="3" />
</ribbon:Ribbon>
I managed to fix the problem by adding the following line of code before i show the WPF Window:
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(this);
This is necessary if you mix WinForms and WPF windows in the same project at least if the WinForm is shown before the WPF window.
In Ribbon cotrol add property: KeyboardNavigation.ControlTabNavigation
<ribbon:Ribbon DockPanel.Dock="Top" SelectedIndex="1" KeyboardNavigation.ControlTabNavigation="Contained">
It's working for me.

Categories