The MouseBinding Tag in XAML is declaring a property „Gesture“, but it is hard to find a full reference / a complete list for all gestures of the MouseBinding tag.
Solution
Accepted gestures can be found in the enumeration MouseAction
RelayCommand (s) erfüllen den Zweck von Actions / Delegates und sind somit Funktionszeiger die es erlauben, zu einem späteren Zeitpunkt eine Methode aufzurufen.
Sie implementieren das Interface ICommand, welches von den WPF Controls genutzt wird, um bei Bedarf die Execute()-Methode aufzurufen. D.h. die Execute()-Methode soll nur dann aufgerufen werden, wenn das WPF Control das Ereignis tatsächlich auslöst und nicht bereits zur Bindung.
Ohne RelayCommands müsste man für jeden Command eine eigene Klasse schreiben, welche vom Interfache ICommand erbt. Sie helfen somit Code einzusparen.
Verwendung in einem MVVM Pattern
Häufige Verwendung: In einer XAML Datei wird ein Button definiert, der an einen RelayCommand gebunden wird, welcher zu einem späteren Zeitpunkt aufgerufen werden soll:
Das ViewModel, welches die View instanziert, muss einen RelayCommand „PerformCalibration“ definieren, der erst aufgerufen wird, wenn der Button geklickt wird (Relay) und nicht sofort bei der Bindung an den ButtonCommand.
Für diesen Zweck beinhaltet das ViewModel, welches die View instanziert, eine Funktion die den RelayCommand zurückgibt:
Der Button ruft die Funktion „Execute“ des implementierten RelayCommands auf, wenn er geklickt wird.
Da RelayCommands „Actions“ sind, haben Sie keinen Rückgabewert.
According to the .NET documentation the Ribbon Control should be available since WPF 4.5, what means is available since .NET Framework 4.5 . But you can not find it? Are you even thinking about the download of the Ribbon control for older versions? Not necessary, please see the following points…
Approach
We have to find out the right moment when it is generally possible to use the Ribbon control.
The following table shows, that the first version of WPF (3.0) was released with the .NET Framework 3.0. As you can see the version number of WPF is maintained synchron with the version number of the .NET framework.
WPF Version
Release (YYYY-MM)
.NET Version
Visual Studio Version
Major Features
3.0
2006-11
3.0
N/A
Initial Release. WPF development can be done with VS 2005 (released in Nov 2005) too with few additions as described here.
3.5
2007-11
3.5
VS 2008
Changes and improvements in: Application model, data binding, controls, documents, annotations, and 3-D UI elements.
3.5 SP1
2008-08
3.5 SP1
N/A
Native splash screen support, New WebBrowser control, DirectX pixel shader support. Faster startup time and improved performance for Bitmap effects.
4.0
2010-04
4.0
VS 2010
New controls: Calendar, DataGrid, and DatePicker. Multi-Touch and Manipulation
4.5
2012-08
4.5
VS 2012
New Ribbon control New INotifyDataErrorInfo interface
4.5.1
2013-10
4.5.1
VS 2013
No Major Change
4.5.2
2014-05
4.5.2
N/A
No Major Change
4.6
2015-07
4.6
VS 2015
Transparent child window support HDPI and Touch improvements
Which WPF Version is included in which version of the .NET Framework?
Solution
When you have installed at least .NET Framework 4.5 you can Add the Reference „System.Windows.Control.Ribbon“ as follows:
1.) Expand the tree in in your Solution Explorer of you WPF application
2.) Right-click the „Add References“ entry and choose „Add Reference“
3.) In the following dialog search for „Ribbon“ in the search field on the upper right
4.) After that you should be able to add the reference by using the checkbox
5.) In your XAML Code you are now able to use the <Ribbon/> Tag
Optional: 6.) If you want to use a RibbonWindow instead of a WPF Window which allows you to have the Quick Access Controls at the top of the window, you have to do the declaration in the head of MainWindow.xaml as follows:
<ribbon:RibbonWindow x:Class="WPFTutorial.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
Title="WPF Layoutmanager" Height="399" Width="763">
<DockPanel LastChildFill="True">
<Ribbon DockPanel.Dock="Top" >
</Ribbon>
<!-- Put the last Child here -->
</DockPanel>
</ribbon:RibbonWindow>
Additionally you have to change the base class name in the code behind window and add the using System.Windows.Controls.Ribbon :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFTutorial
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : RibbonWindow
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Test");
}
}
}
Like in HTML/CSS there are different source code locations where it is possible to apply appearance styles to WPF controls. In this article i want to make a really short summary of those points.
Approach
The following examples are showing the declaration places for styles in the order from local control styles to global application styles