Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8" ?>
- <configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
- </startup>
- </configuration>
- <Application x:Class="Test_Application.App"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- StartupUri="MainWindow.xaml">
- <Application.Resources>
- </Application.Resources>
- </Application>
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows;
- namespace Test_Application
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- }
- }
- <ribbon:RibbonWindow x:Class="Test_Application.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
- xmlns:local="clr-namespace:Test_Application"
- Title="MainWindow" Height="350" Width="525">
- <ribbon:Ribbon>
- <ribbon:Ribbon.Tabs>
- <ribbon:Tab>
- <ribbon:Group>
- <ribbon:StackPanel>
- <ribbon:SplitButton>
- <ribbon:SplitButton.PopupContent>
- <local:PopupContentUC DataContext = "{Binding Path=UCViewModel}"/>
- </ribbon:SplitButton.PopupContent>
- </ribbon:SplitButton>
- </ribbon:StackPanel>
- </ribbon:Group>
- </ribbon:Tab>
- </ribbon:Ribbon.Tabs>
- </ribbon:Ribbon>
- </ribbon:RibbonWindow>
- using ActiproSoftware.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.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 Test_Application
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : RibbonWindow
- {
- PopupContentUCViewModel vm;
- public PopupContentUCViewModel UCViewModel
- {
- get
- {
- if (vm == null)
- {
- vm = new PopupContentUCViewModel();
- }
- return vm;
- }
- }
- public MainWindow()
- {
- this.DataContext = this;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Data;
- namespace Test_Application
- {
- public class MyMultiConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- string text = values[0] as string;
- bool? mouseOver = values[1] as bool?;
- if (text != null && !(mouseOver ?? true))
- {
- return text;
- }
- else
- {
- return "Mouse Over";
- }
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
- <UserControl x:Class="Test_Application.PopupContentUC"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
- xmlns:local="clr-namespace:Test_Application"
- mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
- <UserControl.Resources>
- <local:MyMultiConverter x:Key="multiConverter"/>
- </UserControl.Resources>
- <StackPanel>
- <TextBox Text="{Binding Path=DisplayText, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"/>
- <ribbon:Button StaysOpenOnClick="False">
- <ribbon:Button.Label>
- <MultiBinding Converter="{StaticResource multiConverter}" Mode="OneWay">
- <Binding Path="DisplayText"/>
- <Binding Path="IsMouseOver" RelativeSource="{RelativeSource Self}"/>
- </MultiBinding>
- </ribbon:Button.Label>
- </ribbon:Button>
- </StackPanel>
- </UserControl>
- 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.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 Test_Application
- {
- /// <summary>
- /// Interaction logic for PopupContentUC.xaml
- /// </summary>
- public partial class PopupContentUC : UserControl
- {
- public PopupContentUC()
- {
- InitializeComponent();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Test_Application
- {
- public class PopupContentUCViewModel : INotifyPropertyChanged
- {
- private string _displayText;
- public string DisplayText
- {
- get { return _displayText; }
- set
- {
- _displayText = string.Format("Text: {0}", value);
- if (PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs("DisplayText"));
- }
- }
- }
- public event PropertyChangedEventHandler PropertyChanged;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement