KeyTip not working in Microsoft Ribbon - c#

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.

Related

Cannot select objects in XAML Designer when using dragablz and MahApps

I am developing an application with the use of dragablz, MahApps and MaterialDesign. However, I have broken down the problem to the dragablz and MahApps extension.
I create two tab items (extract from demo code):
<controls:MetroWindow x:Class="MahMaterialDragablzMashUp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
xmlns:mahMaterialDragablzMashUp="clr-namespace:MahMaterialDragablzMashUp"
xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
WindowTransitionsEnabled="False"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
Background="{DynamicResource MaterialDesignPaper}"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
Title="Material-MahApps-Dragablz Mash Up" Height="640" Width="800">
<dockablz:Layout>
<dragablz:TabablzControl BorderThickness="0"
Margin="0,-1,0,1">
<dragablz:TabablzControl.InterTabController>
<dragablz:InterTabController />
</dragablz:TabablzControl.InterTabController>
<TabItem Header="DIALOGS">
<mahMaterialDragablzMashUp:Mah Margin="16" />
</TabItem>
<TabItem Header="MAHAPPS">
<mahMaterialDragablzMashUp:Mah Margin="16" />
</TabItem>
</dragablz:TabablzControl>
</dockablz:Layout>
</controls:MetroWindow>
The code works fine, but when I try to switch to another tab in the XAML designer by clicking on it, the whole section is selected but not any single object, so I cannot click on another tab:
The view in the designer changes when I click into the corresponding code lines in the XAML editor, but not when I click on the object in the designer. This makes simple design steps (like moving buttons around) very difficult as I cannot click and drag them.
Up to now, I have tried the following:
using Visual Studio 2013 Professional
using Visual Studio 2015 Community
Build the project
restart VS and the computer
I found the following question and the provided solution by 'JFTxJ' (that empty Grid elements are causing the problem) is not working for me, as I do not have any Grid items.
Same for the answer from 'Moon Waxing' (to add the attribute Visibility="Collapsed" to the tabiItem) is not working for me.
Other StackOverflow question: Cannot click or select Control XAML design
Is this a common problem or is there any solution to it?

Right align (Help) button on WPF ribbon

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>

Using Caliburn Micro with Microsoft Ribbon Controls and RibbonApplicationMenu

I'm trying to use Caliburn Micro and MVVM for a menu. I'm currently using the Ribbon controls located in System.Windows.Controls.Ribbon. Binding the click event using x:Name works ok for regular buttons in a tab, but the menu items in RibbonApplicationMenu does not work. Is that a bug or do I have to do some extra work in the bootstrapper class to make sure that CM finds the RibbonApplicationMenuItems? I'm on CM v2.0.1.
Some example here:
XAML:
<Ribbon x:Name="Ribbon" >
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu KeyTip="F">
<RibbonApplicationMenuItem Header="{Binding NewText}" x:Name="AppNew" />
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab Header="{Binding OverviewTabText}" >
<RibbonGroup x:Name="MainGroupOverview" Header="{Binding MainGroupText}">
<RibbonButton Label="{Binding NewText}" x:Name="AppNewOverview" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
And in ViewModel class:
public void AppNew()
{
//this will not be called
New();
}
public void AppNewOverview()
{
//this works just fine
New();
}
Still digging on this but for the name attributed doesn't seem to work for anything, actually mocked up a sample on my end. cm:Message.Attach="[Event Click]=[Action NewApp()]" works. Actually strange and you might want to drop by the GitHub repo and fill out if this might actually be an issue. –

WindowsFormsHost error IsRedirected is not found?

I am adding a WINFORM chart to my WPF project using
System.Windows.Forms.Integration.WindowsFormsHost
I am trying to work around the "airspace" rendering issue where the host is always rendered as the top most element the window. The workaround I am using sets
IsRedireced = "true"
When I insert this into my XMAL code:
<Grid x:Name="ssCurveChartGrid" Grid.Column="1" Margin="110,30,160,306" Grid.ColumnSpan="4" RenderTransformOrigin="0.479,0.186">
<WindowsFormsHost IsRedirected =" "true">
</WindowsFormsHost>
</Grid>
or my code behind:
System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();
host.IsRedirected = "true";
I get the following error:
The property 'IsRedirected' was not found in type 'WindowsFormsHost'
Here is a screenshot:
Can anyone help explain why this is happening? I relay need to display an element on top of my WINFORM chart!
Thanks
EDIT:
Code was taken from MSDN site: http://msdn.microsoft.com/en-us/library/ms752027.aspx
From MSDN:
"By default, visible WindowsFormsHost elements are always drawn on top of other WPF elements, and they are unaffected by z-order. To enable z-ordering, set the IsRedirected property of the WindowsFormsHost to true and the CompositionMode property to Full or OutputOnly.
To see the default z-order behavior"
"Copy the following XAML into the Grid element."
<!-- Z-order demonstration. -->
<Canvas Grid.Row="1" Grid.Column="1">
<WindowsFormsHost Canvas.Top="20" Canvas.Left="20" Background="Yellow">
<wf:Button Text="Windows Forms control" FlatStyle="Flat"/>
</WindowsFormsHost>
<Label Content="A WPF label" FontSize="24"/>
</Canvas>
Press F5 to build and run the application. The WindowsFormsHost element is painted over the label element.
"To see the z-order behavior when IsRedirected is true"
Replace the previous z-order example with the following XAML.
XAML
<!-- Z-order demonstration. -->
<Canvas Grid.Row="1" Grid.Column="1">
<WindowsFormsHost IsRedirected="True" CompositionMode="Full" Canvas.Top="20" Canvas.Left="20" Background="Yellow">
<wf:Button Text="Windows Forms control" FlatStyle="Flat"/>
</WindowsFormsHost>
<Label Content="A WPF label" FontSize="24"/>
</Canvas>
Press F5 to build and run the application. The label element is painted over the WindowsFormsHost element.
Microsoft .NET Framework 4.5 Beta Readme
1.3.10 Windows Presentation Foundation (WPF)
1.3.10.1 HwndHost feature has been removed from WPF in the .NET Framework 4.5 Beta
The .NET Framework 4.5 Developer Preview included a WPF HwndHost redirection feature. However, this feature had several known issues and has been removed from the .NET Framework 4.5 Beta. It will not be included in any future releases.
To resolve this issue:
No workaround is available.
(emphasis added)
Which .Net Framework are you using here. IsRedirected for WindowsFormHost is released with Framework 4.5

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