-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainView.xaml
36 lines (33 loc) · 1.88 KB
/
MainView.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
<UserControl x:Class="Example.View.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ViewModel="clr-namespace:Example.ViewModel"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="600">
<UserControl.Resources>
<dxmvvm:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
<dxmvvm:BooleanToObjectConverter x:Key="BooleanToObjectConverter" TrueValue="Saved!" FalseValue="Unsaved!"/>
</UserControl.Resources>
<UserControl.DataContext>
<ViewModel:MainViewModel/>
</UserControl.DataContext>
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Content="Save" Command="{Binding SaveCommand}"/>
<Button Content="Close">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:ConfirmationBehavior EnableConfirmationMessage="{Binding IsSaved, Converter={StaticResource BooleanNegationConverter}}"
Command="{Binding CloseCommand}" MessageText="The document has unsaved changes. Do you want to close the document?"/>
</dxmvvm:Interaction.Behaviors>
</Button>
<TextBlock Text="{Binding IsSaved, Converter={StaticResource BooleanToObjectConverter}}"/>
</StackPanel>
<TextBox Text="{Binding Text, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Row="1"/>
</Grid>
</UserControl>