-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
MainWindow.xaml
77 lines (77 loc) · 3.71 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<Window x:Class="Elmish.WPF.Samples.EventBindingsAndBehaviors.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elmish.WPF.Samples.EventBindingsAndBehaviors"
xmlns:vm="clr-namespace:Elmish.WPF.Samples.EventBindingsAndBehaviors;assembly=EventBindingsAndBehaviors.Core"
Title="EventBindings"
Height="450"
Width="400"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
d:DataContext="{x:Static vm:Program.designVm}">
<Window.InputBindings>
<KeyBinding Command="{Binding ToggleVisibility}" Gesture="Ctrl+T" />
</Window.InputBindings>
<StackPanel Margin="15" HorizontalAlignment="Center">
<TextBlock Text="Switch focus between these two inputs." Margin="0,0,0,10" TextAlignment="Center" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel Margin="0,0,25,0">
<TextBox Width="100" IsReadOnly="True" IsReadOnlyCaretVisible="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="GotFocus">
<i:InvokeCommandAction Command="{Binding GotFocus1}"/>
</i:EventTrigger>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding LostFocus1}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBlock Text="{Binding Msg1}" Margin="0,0,25,0" TextAlignment="Center" />
</StackPanel>
<StackPanel Margin="0,0,0,0">
<TextBox Width="100" IsReadOnly="True" IsReadOnlyCaretVisible="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="GotFocus">
<i:InvokeCommandAction Command="{Binding GotFocus2}"/>
</i:EventTrigger>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding LostFocus2}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBlock Text="{Binding Msg2}" Margin="0,0,25,0" TextAlignment="Center" />
</StackPanel>
</StackPanel>
<Button Command="{Binding ToggleVisibility}" Content="{Binding ButtonText}" Width="100" Height="25" Margin="0,20,0,0">
<Button.ToolTip>
<TextBlock>
<Run Text="{Binding ButtonText}" />
<Run Text="(Ctrl + T)" />
</TextBlock>
</Button.ToolTip>
</Button>
<TextBlock
Text="This input will receive focus automatically each time it appears."
TextWrapping="Wrap"
Margin="0,10,0,10"
TextAlignment="Center" />
<TextBox Width="100" Margin="0,0,0,0" Visibility="{Binding TextBoxVisibility}" IsReadOnly="True" IsReadOnlyCaretVisible="True">
<i:Interaction.Behaviors>
<local:FocusWhenVisibleBehavior />
</i:Interaction.Behaviors>
</TextBox>
<Separator Margin="0,16,0,16"/>
<TextBlock Text="MouseEventArgs given to command as parameter when the MoveMouse event is triggered inside the ellipse." TextWrapping="Wrap"/>
<TextBlock Text="{Binding MousePosition, StringFormat='Mouse Position is {0}'}" Margin="0,16,0,16"/>
<Ellipse Fill="LightGray" Stroke="Black" Height="100" Width="300">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseMove">
<i:InvokeCommandAction PassEventArgsToCommand="True" Command="{Binding MouseMoveCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Ellipse>
</StackPanel>
</Window>