CHG Reformatting code (NTFY-20).

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@192 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2013-11-18 00:03:09 +00:00
parent 1be7b176a9
commit 7014294506
64 changed files with 3832 additions and 3636 deletions

View File

@@ -1,19 +1,21 @@
<Window
x:Class="Samples.Tutorials.SimpleWindowWithNotifyIcon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
x:Class="Samples.Tutorials.SimpleWindowWithNotifyIcon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<!-- in order to declare a NotifyIcon, all you need is the
<!-- in order to declare a NotifyIcon, all you need is the
namespace declaration (see above on line 5) and a single line -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world" />
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="You should see an icon in the tray." Language="de-ch"/></TextBlock>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world" />
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap">
<Run Text="You should see an icon in the tray." Language="de-ch" />
</TextBlock>
</Grid>
</Window>
</Grid>
</Window>

View File

@@ -2,22 +2,22 @@
namespace Samples.Tutorials
{
/// <summary>
/// Interaction logic for SimpleWindowWithNotifyIcon.xaml
/// </summary>
public partial class SimpleWindowWithNotifyIcon : Window
{
public SimpleWindowWithNotifyIcon()
/// <summary>
/// Interaction logic for SimpleWindowWithNotifyIcon.xaml
/// </summary>
public partial class SimpleWindowWithNotifyIcon : Window
{
InitializeComponent();
}
public SimpleWindowWithNotifyIcon()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
base.OnClosing(e);
}
}
}
}

View File

@@ -1,40 +1,41 @@
<Window
x:Class="Samples.Tutorials.ToolTips.InlineToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
x:Class="Samples.Tutorials.ToolTips.InlineToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!--
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!--
We can use arbitrary UI elements as ToolTips.
Let's use a semi-transparent border.
-->
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="hello world"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="hello world"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
</Grid>
</Window>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap">
<Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch" />
</TextBlock>
</Grid>
</Window>

View File

@@ -13,22 +13,22 @@ using System.Windows.Shapes;
namespace Samples.Tutorials.ToolTips
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class InlineToolTipWindow : Window
{
public InlineToolTipWindow()
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class InlineToolTipWindow : Window
{
InitializeComponent();
}
public InlineToolTipWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
base.OnClosing(e);
}
}
}
}
}

View File

@@ -1,22 +1,21 @@
<UserControl
x:Class="Samples.Tutorials.ToolTips.SimpleUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
x:Class="Samples.Tutorials.ToolTips.SimpleUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- a simple user control which displays a fixed text within a border -->
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="hello world"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</UserControl>
<!-- a simple user control which displays a fixed text within a border -->
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="hello world"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</UserControl>

View File

@@ -14,14 +14,14 @@ using System.Windows.Shapes;
namespace Samples.Tutorials.ToolTips
{
/// <summary>
/// Interaction logic for SimpleUserControl.xaml
/// </summary>
public partial class SimpleUserControl : UserControl
{
public SimpleUserControl()
/// <summary>
/// Interaction logic for SimpleUserControl.xaml
/// </summary>
public partial class SimpleUserControl : UserControl
{
InitializeComponent();
public SimpleUserControl()
{
InitializeComponent();
}
}
}
}
}

View File

@@ -1,25 +1,27 @@
<Window
x:Class="Samples.Tutorials.ToolTips.UserControlToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.ToolTips"
Height="300"
Width="300">
<Grid>
x:Class="Samples.Tutorials.ToolTips.UserControlToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.ToolTips"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!-- assign user control as ToolTip -->
<tb:TaskbarIcon.TrayToolTip>
<local:SimpleUserControl />
</tb:TaskbarIcon.TrayToolTip>
<!-- assign user control as ToolTip -->
<tb:TaskbarIcon.TrayToolTip>
<local:SimpleUserControl />
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap">
<Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch" />
</TextBlock>
</Grid>
</Window>
</Grid>
</Window>

View File

@@ -13,22 +13,22 @@ using System.Windows.Shapes;
namespace Samples.Tutorials.ToolTips
{
/// <summary>
/// Interaction logic for UserControlToolTipWindow.xaml
/// </summary>
public partial class UserControlToolTipWindow : Window
{
public UserControlToolTipWindow()
/// <summary>
/// Interaction logic for UserControlToolTipWindow.xaml
/// </summary>
public partial class UserControlToolTipWindow : Window
{
InitializeComponent();
}
public UserControlToolTipWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
base.OnClosing(e);
}
}
}
}
}

View File

@@ -1,58 +1,58 @@
<Window
x:Class="Samples.Tutorials.Popups.InlinePopupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
x:Class="Samples.Tutorials.Popups.InlinePopupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!--
<!--
We can use arbitrary UI elements as Popups.
Popups stay open if the user moves away from the tray area
-->
<tb:TaskbarIcon.TrayPopup>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Width="160">
<StackPanel>
<TextBox
x:Name="popupText"
Margin="5,10,5,10"
Width="200"
Height="24"
Text="Enter Text..." />
<Button
Content="Click Me!"
Margin="5,0,5,10"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</StackPanel>
</Border>
</tb:TaskbarIcon.TrayPopup>
<tb:TaskbarIcon.TrayPopup>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Width="160">
<StackPanel>
<TextBox
x:Name="popupText"
Margin="5,10,5,10"
Width="200"
Height="24"
Text="Enter Text..." />
<Button
Content="Click Me!"
Margin="5,0,5,10"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</StackPanel>
</Border>
</tb:TaskbarIcon.TrayPopup>
</tb:TaskbarIcon>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
Text="Left-Click NotifyIcon to open popup." />
<TextBlock
Text="Text on Popup: "
Margin="26,66,24,0"
VerticalAlignment="Top">
<TextBlock Foreground="Red"
Text="{Binding ElementName=popupText, Path=Text}" />
</TextBlock>
</tb:TaskbarIcon>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
Text="Left-Click NotifyIcon to open popup." />
</Grid>
<TextBlock
Text="Text on Popup: "
Margin="26,66,24,0"
VerticalAlignment="Top">
<TextBlock Foreground="Red"
Text="{Binding ElementName=popupText, Path=Text}" />
</TextBlock>
</Grid>
</Window>

View File

@@ -13,22 +13,22 @@ using System.Windows.Shapes;
namespace Samples.Tutorials.Popups
{
/// <summary>
/// Interaction logic for InlinePopupWindow.xaml
/// </summary>
public partial class InlinePopupWindow : Window
{
public InlinePopupWindow()
/// <summary>
/// Interaction logic for InlinePopupWindow.xaml
/// </summary>
public partial class InlinePopupWindow : Window
{
InitializeComponent();
}
public InlinePopupWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
base.OnClosing(e);
}
}
}
}
}

View File

@@ -46,8 +46,10 @@
<TextBlock Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
TextWrapping="Wrap"><Run Language="de-ch"
Text="Right-click on NotifyIcon to open Context Menu" /></TextBlock>
TextWrapping="Wrap">
<Run Language="de-ch"
Text="Right-click on NotifyIcon to open Context Menu" />
</TextBlock>
<TextBlock HorizontalAlignment="Left"
Margin="26,83,0,0"
TextWrapping="Wrap"

View File

@@ -32,7 +32,7 @@ namespace Samples.Tutorials.ContextMenus
private void MyNotifyIcon_PreviewTrayContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
{
//marking the event as handled suppresses the context menu
e.Handled = (bool)SuppressContextMenu.IsChecked;
e.Handled = (bool) SuppressContextMenu.IsChecked;
PreviewOpenEventCounter.Text = (int.Parse(PreviewOpenEventCounter.Text) + 1).ToString();
}

View File

@@ -1,54 +1,51 @@
<Window
x:Class="Samples.Tutorials.Balloons.BalloonSampleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
x:Class="Samples.Tutorials.Balloons.BalloonSampleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="Balloon Sample Icon" />
<Button
x:Name="btnShowStandardBalloon"
Click="btnShowStandardBalloon_Click"
Margin="26,74,29,0"
Content="Show Standard Balloon" Height="29" VerticalAlignment="Top"
/>
<Button
x:Name="btnShowCustomBalloon"
Click="btnShowCustomBalloon_Click"
Margin="26,0,29,49"
VerticalAlignment="Bottom"
Height="27"
Content="Show Custom Balloon"
/>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="Clicking on buttons shows balloon tips" /></TextBlock>
<Button
x:Name="btnHideStandardBalloon"
Click="btnHideStandardBalloon_Click"
Margin="26,113,29,122"
Content="Hide Standard Balloon"
/>
<Button
x:Name="btnCloseCustomBalloon"
Click="btnCloseCustomBalloon_Click"
Margin="26,0,29,12"
VerticalAlignment="Bottom"
Height="27"
Content="Close Custom Balloon"
/>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="Balloon Sample Icon" />
<Button
x:Name="btnShowStandardBalloon"
Click="btnShowStandardBalloon_Click"
Margin="26,74,29,0"
Content="Show Standard Balloon" Height="29" VerticalAlignment="Top" />
<Button
x:Name="btnShowCustomBalloon"
Click="btnShowCustomBalloon_Click"
Margin="26,0,29,49"
VerticalAlignment="Bottom"
Height="27"
Content="Show Custom Balloon" />
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
TextWrapping="Wrap">
<Run
Language="de-ch"
Text="Clicking on buttons shows balloon tips" />
</TextBlock>
<Button
x:Name="btnHideStandardBalloon"
Click="btnHideStandardBalloon_Click"
Margin="26,113,29,122"
Content="Hide Standard Balloon" />
<Button
x:Name="btnCloseCustomBalloon"
Click="btnCloseCustomBalloon_Click"
Margin="26,0,29,12"
VerticalAlignment="Bottom"
Height="27"
Content="Close Custom Balloon" />
</Grid>
</Window>
</Grid>
</Window>

View File

@@ -15,53 +15,51 @@ using Hardcodet.Wpf.TaskbarNotification;
namespace Samples.Tutorials.Balloons
{
/// <summary>
/// Interaction logic for BalloonSampleWindow.xaml
/// </summary>
public partial class BalloonSampleWindow : Window
{
public BalloonSampleWindow()
/// <summary>
/// Interaction logic for BalloonSampleWindow.xaml
/// </summary>
public partial class BalloonSampleWindow : Window
{
InitializeComponent();
public BalloonSampleWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
private void btnShowCustomBalloon_Click(object sender, RoutedEventArgs e)
{
FancyBalloon balloon = new FancyBalloon();
balloon.BalloonText = "Custom Balloon";
//show balloon and close it after 4 seconds
MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);
}
private void btnHideStandardBalloon_Click(object sender, RoutedEventArgs e)
{
MyNotifyIcon.HideBalloonTip();
}
private void btnShowStandardBalloon_Click(object sender, RoutedEventArgs e)
{
string title = "WPF NotifyIcon";
string text = "This is a standard balloon";
MyNotifyIcon.ShowBalloonTip(title, text, MyNotifyIcon.Icon);
}
private void btnCloseCustomBalloon_Click(object sender, RoutedEventArgs e)
{
MyNotifyIcon.CloseBalloon();
}
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
private void btnShowCustomBalloon_Click(object sender, RoutedEventArgs e)
{
FancyBalloon balloon = new FancyBalloon();
balloon.BalloonText = "Custom Balloon";
//show balloon and close it after 4 seconds
MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);
}
private void btnHideStandardBalloon_Click(object sender, RoutedEventArgs e)
{
MyNotifyIcon.HideBalloonTip();
}
private void btnShowStandardBalloon_Click(object sender, RoutedEventArgs e)
{
string title = "WPF NotifyIcon";
string text = "This is a standard balloon";
MyNotifyIcon.ShowBalloonTip(title, text, MyNotifyIcon.Icon);
}
private void btnCloseCustomBalloon_Click(object sender, RoutedEventArgs e)
{
MyNotifyIcon.CloseBalloon();
}
}
}
}

View File

@@ -1,58 +1,64 @@
<Window
x:Class="Samples.Tutorials.Commands.CommandWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
Height="300"
Width="300"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
x:Class="Samples.Tutorials.Commands.CommandWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
Height="300"
Width="300"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<!-- declare the command as a local resource -->
<Grid.Resources>
<local:ShowMessageCommand
x:Key="MessageCommand" />
</Grid.Resources>
<!-- declare the command as a local resource -->
<Grid.Resources>
<local:ShowMessageCommand
x:Key="MessageCommand" />
</Grid.Resources>
<!-- declare the NotifyIcon and configure commands with parameters -->
<tb:TaskbarIcon
x:Name="CustomCommandNotifyIcon"
IconSource="/Icons/Error.ico"
LeftClickCommand="{StaticResource MessageCommand}"
LeftClickCommandParameter="Left mouse button was clicked"
DoubleClickCommand="{StaticResource MessageCommand}"
DoubleClickCommandParameter="Double click on NotifyIcon" />
<!-- declare the NotifyIcon and configure commands with parameters -->
<tb:TaskbarIcon
x:Name="CustomCommandNotifyIcon"
IconSource="/Icons/Error.ico"
LeftClickCommand="{StaticResource MessageCommand}"
LeftClickCommandParameter="Left mouse button was clicked"
DoubleClickCommand="{StaticResource MessageCommand}"
DoubleClickCommandParameter="Double click on NotifyIcon" />
<!-- declare the NotifyIcon and configure commands with targets -->
<tb:TaskbarIcon
x:Name="RoutedCommandNotifyIcon"
IconSource="/Icons/Inactive.ico"
LeftClickCommand="ApplicationCommands.Cut"
LeftClickCommandTarget="{Binding ElementName=txtInput}"
DoubleClickCommand="ApplicationCommands.Paste"
DoubleClickCommandTarget="{Binding ElementName=txtInput}" />
<!-- declare the NotifyIcon and configure commands with targets -->
<tb:TaskbarIcon
x:Name="RoutedCommandNotifyIcon"
IconSource="/Icons/Inactive.ico"
LeftClickCommand="ApplicationCommands.Cut"
LeftClickCommandTarget="{Binding ElementName=txtInput}"
DoubleClickCommand="ApplicationCommands.Paste"
DoubleClickCommandTarget="{Binding ElementName=txtInput}" />
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="Left / Double clicks on red NotifyIcon executes simple custom commands." /></TextBlock>
<TextBlock
Margin="26,112,24,80"
FontWeight="Bold"
TextWrapping="Wrap"><Run Language="de-ch" Text="Left / Double clicks on grey NotifyIcon executes routed commands."/><LineBreak/><Run Language="de-ch" Text="Single click: Cuts selected text"/><LineBreak/><Run Language="de-ch" Text="Double click: Paste text from clipboard"/></TextBlock>
<TextBox
Margin="26,0,24,48"
VerticalAlignment="Bottom"
Height="22"
Text="hello world"
TextWrapping="Wrap"
x:Name="txtInput" />
</Grid>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
TextWrapping="Wrap">
<Run
Language="de-ch"
Text="Left / Double clicks on red NotifyIcon executes simple custom commands." />
</TextBlock>
<TextBlock
Margin="26,112,24,80"
FontWeight="Bold"
TextWrapping="Wrap">
<Run Language="de-ch" Text="Left / Double clicks on grey NotifyIcon executes routed commands." />
<LineBreak /><Run Language="de-ch" Text="Single click: Cuts selected text" /><LineBreak />
<Run Language="de-ch" Text="Double click: Paste text from clipboard" />
</TextBlock>
<TextBox
Margin="26,0,24,48"
VerticalAlignment="Bottom"
Height="22"
Text="hello world"
TextWrapping="Wrap"
x:Name="txtInput" />
</Grid>
</Window>

View File

@@ -13,24 +13,24 @@ using System.Windows.Shapes;
namespace Samples.Tutorials.Commands
{
/// <summary>
/// Interaction logic for CommandWindow.xaml
/// </summary>
public partial class CommandWindow : Window
{
public CommandWindow()
/// <summary>
/// Interaction logic for CommandWindow.xaml
/// </summary>
public partial class CommandWindow : Window
{
InitializeComponent();
public CommandWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
CustomCommandNotifyIcon.Dispose();
RoutedCommandNotifyIcon.Dispose();
base.OnClosing(e);
}
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
CustomCommandNotifyIcon.Dispose();
RoutedCommandNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}
}

View File

@@ -4,22 +4,22 @@ using System.Windows.Input;
namespace Samples.Tutorials.Commands
{
/// <summary>
/// A simple command that displays the command parameter as
/// a dialog message.
/// </summary>
public class ShowMessageCommand : ICommand
{
public void Execute(object parameter)
/// <summary>
/// A simple command that displays the command parameter as
/// a dialog message.
/// </summary>
public class ShowMessageCommand : ICommand
{
MessageBox.Show(parameter.ToString());
}
public void Execute(object parameter)
{
MessageBox.Show(parameter.ToString());
}
public bool CanExecute(object parameter)
{
return true;
}
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
}
}
public event EventHandler CanExecuteChanged;
}
}

View File

@@ -1,259 +1,265 @@
<Window
x:Class="Samples.Tutorials.Events.EventVisualizerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Window.Resources>
<Storyboard
x:Key="ShowMovement"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="MoveIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.2" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="MoveIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.2" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard
x:Key="ShowMouseUp"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="LeftMouseIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.35" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="LeftMouseIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.35" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard
x:Key="ShowToolTipOpened"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ToolTipIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.2000000"
Value="1.4" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ToolTipIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.2000000"
Value="1.4" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayMouseMove"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowMovement}" />
</EventTrigger>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayLeftMouseUp"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowMouseUp}"
x:Name="ShowMouseUp_BeginStoryboard" />
</EventTrigger>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowToolTipOpened}"
x:Name="ShowToolTipOpened_BeginStoryboard" />
</EventTrigger>
</Window.Triggers>
<Grid>
x:Class="Samples.Tutorials.Events.EventVisualizerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Window.Resources>
<Storyboard
x:Key="ShowMovement"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="MoveIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.2" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="MoveIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.2" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard
x:Key="ShowMouseUp"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="LeftMouseIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.35" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="LeftMouseIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.35" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard
x:Key="ShowToolTipOpened"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ToolTipIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.2000000"
Value="1.4" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ToolTipIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.2000000"
Value="1.4" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayMouseMove"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowMovement}" />
</EventTrigger>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayLeftMouseUp"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowMouseUp}"
x:Name="ShowMouseUp_BeginStoryboard" />
</EventTrigger>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowToolTipOpened}"
x:Name="ShowToolTipOpened_BeginStoryboard" />
</EventTrigger>
</Window.Triggers>
<Grid>
<!-- the NotifyIcon does not need to be configured here - animations were set up in Blend -->
<tb:TaskbarIcon
x:Name="notifyIcon"
ToolTipText="hello world"
IconSource="/Icons/Error.ico" />
<!-- the NotifyIcon does not need to be configured here - animations were set up in Blend -->
<tb:TaskbarIcon
x:Name="notifyIcon"
ToolTipText="hello world"
IconSource="/Icons/Error.ico" />
<Ellipse
HorizontalAlignment="Left"
Margin="24,62,0,0"
VerticalAlignment="Top"
Width="19"
Height="19"
Stroke="#FF549D2D"
x:Name="MoveIndicator"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1" />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse
Stroke="#FF549D2D"
HorizontalAlignment="Left"
Margin="24,106,0,0"
VerticalAlignment="Top"
Width="19"
Height="19"
x:Name="LeftMouseIndicator"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse
Stroke="#FF549D2D"
HorizontalAlignment="Left"
Margin="24,0,0,94"
Width="19"
x:Name="ToolTipIndicator"
RenderTransformOrigin="0.5,0.5"
Height="19"
VerticalAlignment="Bottom">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1" />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock
Margin="63,62,91,0"
VerticalAlignment="Top"
Height="19"
TextWrapping="Wrap">
<Run
Language="de-ch"
Text="TrayMouseMove Event" />
</TextBlock>
<TextBlock
Margin="63,106,91,0"
VerticalAlignment="Top"
Height="19"
TextWrapping="Wrap">
<Run
Language="de-ch"
Text="TrayLeftMouseUp Event" />
</TextBlock>
<TextBlock
Margin="63,0,91,94"
TextWrapping="Wrap"
VerticalAlignment="Bottom"
Height="19">
<Run
Language="de-ch"
Text="TrayToolTipOpen Event" />
</TextBlock>
<TextBlock
Margin="10,10,10,0"
VerticalAlignment="Top"
Height="31"
TextWrapping="Wrap"
FontWeight="Bold">
<Run Language="de-ch" Text="The green ellipses are animated based on routed events of the NotifyIcon" />
</TextBlock>
<Ellipse
HorizontalAlignment="Left"
Margin="24,62,0,0"
VerticalAlignment="Top"
Width="19"
Height="19"
Stroke="#FF549D2D"
x:Name="MoveIndicator"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1" />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse
Stroke="#FF549D2D"
HorizontalAlignment="Left"
Margin="24,106,0,0"
VerticalAlignment="Top"
Width="19"
Height="19"
x:Name="LeftMouseIndicator"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse
Stroke="#FF549D2D"
HorizontalAlignment="Left"
Margin="24,0,0,94"
Width="19"
x:Name="ToolTipIndicator"
RenderTransformOrigin="0.5,0.5"
Height="19"
VerticalAlignment="Bottom">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1" />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock
Margin="63,62,91,0"
VerticalAlignment="Top"
Height="19"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="TrayMouseMove Event" /></TextBlock>
<TextBlock
Margin="63,106,91,0"
VerticalAlignment="Top"
Height="19"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="TrayLeftMouseUp Event" /></TextBlock>
<TextBlock
Margin="63,0,91,94"
TextWrapping="Wrap"
VerticalAlignment="Bottom"
Height="19"><Run
Language="de-ch"
Text="TrayToolTipOpen Event" /></TextBlock>
<TextBlock
Margin="10,10,10,0"
VerticalAlignment="Top"
Height="31"
TextWrapping="Wrap"
FontWeight="Bold"><Run Language="de-ch" Text="The green ellipses are animated based on routed events of the NotifyIcon"/></TextBlock>
</Grid>
</Grid>
</Window>

View File

@@ -2,23 +2,23 @@
namespace Samples.Tutorials.Events
{
/// <summary>
/// Interaction logic for EventVisualizerWindow.xaml
/// </summary>
public partial class EventVisualizerWindow : Window
{
public EventVisualizerWindow()
/// <summary>
/// Interaction logic for EventVisualizerWindow.xaml
/// </summary>
public partial class EventVisualizerWindow : Window
{
InitializeComponent();
public EventVisualizerWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
notifyIcon.Dispose();
base.OnClosing(e);
}
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
notifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -1,97 +1,101 @@
<Window
x:Class="Samples.Tutorials.DataBinding.DataBoundToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="500">
<Grid>
x:Class="Samples.Tutorials.DataBinding.DataBoundToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="500">
<Grid>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon1"
IconSource="/Icons/Error.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon1"
IconSource="/Icons/Error.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<!--
<!--
The TextBlock bound to the ToolTipText property of the NotifyIcon
The binding is implicit (using DataContext)
-->
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="{Binding Path=ToolTipText}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="{Binding Path=ToolTipText}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
</tb:TaskbarIcon>
<!-- This NotifyIcon has its DataContext set (just the string "WPF FTW") - implicit binding is no longer possible -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon2"
DataContext="WPF FTW "
IconSource="/Icons/Inactive.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<!-- This NotifyIcon has its DataContext set (just the string "WPF FTW") - implicit binding is no longer possible -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon2"
DataContext="WPF FTW "
IconSource="/Icons/Inactive.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<tb:TaskbarIcon.TrayToolTip>
<!--
<tb:TaskbarIcon.TrayToolTip>
<!--
Important: The attached property is assigned to the border, but derived by all controls.
The NotifyIcon does not touch the underlying controls.
-->
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<!-- Implicitly access the DataContext (which is a string this time)-->
<TextBlock Text="{Binding}">
<!-- Explicitly access the NotifyIcon, as it is an attached property -->
<TextBlock
Text="{Binding RelativeSource={RelativeSource Self},
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<!-- Implicitly access the DataContext (which is a string this time)-->
<TextBlock Text="{Binding}">
<!-- Explicitly access the NotifyIcon, as it is an attached property -->
<TextBlock
Text="{Binding RelativeSource={RelativeSource Self},
Path=(tb:TaskbarIcon.ParentTaskbarIcon).ToolTipText}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</TextBlock>
</Border>
</tb:TaskbarIcon.TrayToolTip>
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</TextBlock>
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
</tb:TaskbarIcon>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
TextWrapping="Wrap"
FontWeight="Bold">
<Run Text="This sample shows data bound ToolTips in two flavors" /><LineBreak /><Run Text="" />
<LineBreak /><Run Text="- implicit binding via DataContext" /><LineBreak />
<Run Text="- explicit binding via ParentTaskbarIcon (attached property)" /><LineBreak /><Run Text="" />
<LineBreak /><Run Text="Move over NotifyIcons (grey / red) to show data bound ToolTip" />
</TextBlock>
<TextBox
Margin="26,0,24,10"
Text="hello world"
TextWrapping="Wrap"
x:Name="txtToolTip" Height="25" VerticalAlignment="Bottom" />
<TextBlock
Margin="26,0,125,45"
VerticalAlignment="Bottom"
Height="26"
TextWrapping="Wrap">
<Run
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
TextWrapping="Wrap"
FontWeight="Bold"><Run Text="This sample shows data bound ToolTips in two flavors"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="- implicit binding via DataContext"/><LineBreak/><Run Text="- explicit binding via ParentTaskbarIcon (attached property)"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="Move over NotifyIcons (grey / red) to show data bound ToolTip"/></TextBlock>
<TextBox
Margin="26,0,24,10"
Text="hello world"
TextWrapping="Wrap"
x:Name="txtToolTip" Height="25" VerticalAlignment="Bottom" />
<TextBlock
Margin="26,0,125,45"
VerticalAlignment="Bottom"
Height="26"
TextWrapping="Wrap"><Run
Text="ToolTipText:" /></TextBlock>
Text="ToolTipText:" />
</TextBlock>
</Grid>
</Window>
</Grid>
</Window>

View File

@@ -2,24 +2,24 @@
namespace Samples.Tutorials.DataBinding
{
/// <summary>
/// Interaction logic for DataBoundToolTipWindow.xaml
/// </summary>
public partial class DataBoundToolTipWindow : Window
{
public DataBoundToolTipWindow()
/// <summary>
/// Interaction logic for DataBoundToolTipWindow.xaml
/// </summary>
public partial class DataBoundToolTipWindow : Window
{
InitializeComponent();
public DataBoundToolTipWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon1.Dispose();
MyNotifyIcon2.Dispose();
base.OnClosing(e);
}
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon1.Dispose();
MyNotifyIcon2.Dispose();
base.OnClosing(e);
}
}
}