Guest User

Actipro Ribbon Example

a guest
Aug 30th, 2016
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3.     <startup>
  4.         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  5.     </startup>
  6. </configuration>
  7.  
  8. <Application x:Class="Test_Application.App"
  9.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  10.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  11.              StartupUri="MainWindow.xaml">
  12.     <Application.Resources>
  13.          
  14.     </Application.Resources>
  15. </Application>
  16.  
  17.  
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Configuration;
  21. using System.Data;
  22. using System.Linq;
  23. using System.Threading.Tasks;
  24. using System.Windows;
  25.  
  26. namespace Test_Application
  27. {
  28.    /// <summary>
  29.    /// Interaction logic for App.xaml
  30.    /// </summary>
  31.    public partial class App : Application
  32.    {
  33.    }
  34. }
  35.  
  36.  
  37. <ribbon:RibbonWindow x:Class="Test_Application.MainWindow"
  38.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  39.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  40.         xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
  41.         xmlns:local="clr-namespace:Test_Application"
  42.         Title="MainWindow" Height="350" Width="525">
  43.    <ribbon:Ribbon>
  44.       <ribbon:Ribbon.Tabs>
  45.          <ribbon:Tab>
  46.             <ribbon:Group>
  47.                <ribbon:StackPanel>
  48.                   <ribbon:SplitButton>
  49.                      <ribbon:SplitButton.PopupContent>
  50.                         <local:PopupContentUC DataContext = "{Binding Path=UCViewModel}"/>
  51.                      </ribbon:SplitButton.PopupContent>
  52.                   </ribbon:SplitButton>
  53.                </ribbon:StackPanel>
  54.             </ribbon:Group>
  55.          </ribbon:Tab>
  56.       </ribbon:Ribbon.Tabs>
  57.    </ribbon:Ribbon>
  58. </ribbon:RibbonWindow>
  59.  
  60.  
  61. using ActiproSoftware.Windows.Controls.Ribbon;
  62. using System;
  63. using System.Collections.Generic;
  64. using System.Linq;
  65. using System.Text;
  66. using System.Threading.Tasks;
  67. using System.Windows;
  68. using System.Windows.Controls;
  69. using System.Windows.Data;
  70. using System.Windows.Documents;
  71. using System.Windows.Input;
  72. using System.Windows.Media;
  73. using System.Windows.Media.Imaging;
  74. using System.Windows.Navigation;
  75. using System.Windows.Shapes;
  76.  
  77. namespace Test_Application
  78. {
  79.    /// <summary>
  80.    /// Interaction logic for MainWindow.xaml
  81.    /// </summary>
  82.    public partial class MainWindow : RibbonWindow
  83.    {
  84.  
  85.       PopupContentUCViewModel vm;
  86.  
  87.       public PopupContentUCViewModel UCViewModel
  88.       {
  89.          get
  90.          {
  91.             if (vm == null)
  92.             {
  93.                vm = new PopupContentUCViewModel();
  94.             }
  95.             return vm;
  96.          }
  97.       }
  98.  
  99.       public MainWindow()
  100.       {
  101.          this.DataContext = this;
  102.       }
  103.  
  104.  
  105.    }
  106. }
  107.  
  108.  
  109. using System;
  110. using System.Collections.Generic;
  111. using System.Linq;
  112. using System.Text;
  113. using System.Threading.Tasks;
  114. using System.Windows.Data;
  115.  
  116. namespace Test_Application
  117. {
  118.    public class MyMultiConverter : IMultiValueConverter
  119.    {
  120.       public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  121.       {
  122.          string text = values[0] as string;
  123.          bool? mouseOver = values[1] as bool?;
  124.          if (text != null && !(mouseOver ?? true))
  125.          {
  126.             return text;
  127.          }
  128.          else
  129.          {
  130.             return "Mouse Over";
  131.          }
  132.       }
  133.  
  134.       public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
  135.       {
  136.          throw new NotImplementedException();
  137.       }
  138.    }
  139. }
  140.  
  141.  
  142. <UserControl x:Class="Test_Application.PopupContentUC"
  143.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  144.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  145.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  146.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  147.              xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
  148.              xmlns:local="clr-namespace:Test_Application"
  149.              mc:Ignorable="d"
  150.              d:DesignHeight="300" d:DesignWidth="300">
  151.    <UserControl.Resources>
  152.       <local:MyMultiConverter x:Key="multiConverter"/>
  153.    </UserControl.Resources>
  154.    <StackPanel>
  155.       <TextBox Text="{Binding Path=DisplayText, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"/>
  156.       <ribbon:Button StaysOpenOnClick="False">
  157.          <ribbon:Button.Label>
  158.             <MultiBinding Converter="{StaticResource multiConverter}" Mode="OneWay">
  159.                <Binding Path="DisplayText"/>
  160.                <Binding Path="IsMouseOver" RelativeSource="{RelativeSource Self}"/>
  161.             </MultiBinding>
  162.          </ribbon:Button.Label>
  163.       </ribbon:Button>
  164.    </StackPanel>
  165. </UserControl>
  166.  
  167.  
  168. using System;
  169. using System.Collections.Generic;
  170. using System.Linq;
  171. using System.Text;
  172. using System.Threading.Tasks;
  173. using System.Windows;
  174. using System.Windows.Controls;
  175. using System.Windows.Data;
  176. using System.Windows.Documents;
  177. using System.Windows.Input;
  178. using System.Windows.Media;
  179. using System.Windows.Media.Imaging;
  180. using System.Windows.Navigation;
  181. using System.Windows.Shapes;
  182.  
  183. namespace Test_Application
  184. {
  185.    /// <summary>
  186.    /// Interaction logic for PopupContentUC.xaml
  187.    /// </summary>
  188.    public partial class PopupContentUC : UserControl
  189.    {
  190.       public PopupContentUC()
  191.       {
  192.          InitializeComponent();
  193.       }
  194.    }
  195. }
  196.  
  197.  
  198. using System;
  199. using System.Collections.Generic;
  200. using System.ComponentModel;
  201. using System.Linq;
  202. using System.Text;
  203. using System.Threading.Tasks;
  204.  
  205. namespace Test_Application
  206. {
  207.    public class PopupContentUCViewModel : INotifyPropertyChanged
  208.    {
  209.  
  210.       private string _displayText;
  211.  
  212.       public string DisplayText
  213.       {
  214.          get { return _displayText; }
  215.          set
  216.          {
  217.             _displayText = string.Format("Text: {0}", value);
  218.             if (PropertyChanged != null)
  219.             {
  220.                PropertyChanged(this, new PropertyChangedEventArgs("DisplayText"));
  221.             }
  222.          }
  223.       }
  224.  
  225.       public event PropertyChangedEventHandler PropertyChanged;
  226.    }
  227. }
RAW Paste Data