summaryrefslogtreecommitdiff
path: root/src/MVPtoMVVM.mvvm/MainWindow.xaml
blob: 5fabe37fa77e4001ff25887950d849e9a5073a02 (plain)
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
<Window x:Class="MVPtoMVVM.mvvm.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <DockPanel LastChildFill="False">
        <DockPanel.Resources>
            <Style x:Key="ValidationStyle" TargetType="Control">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="Control.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                <Setter Property="Control.BorderBrush" Value="Red" />
                <Setter Property="Control.BorderThickness" Value="2" />
            </Trigger>
        </Style.Triggers>
        </Style>
        </DockPanel.Resources>
        <ListView DockPanel.Dock="Top" ItemsSource="{Binding Path=TodoItems}">
            <ListView.ItemTemplate>
                <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <Image Source="alert.png" Visibility="{Binding Path=ShowDueSoonAlert, Mode=OneWay}"/>
                    <TextBox Width="200" Text="{Binding Path=Description, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ResourceKey=ValidationStyle}" />
                    <DatePicker SelectedDate="{Binding Path=DueDate, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ResourceKey=ValidationStyle}" />
                    <Button Content="Save" Command="{Binding Path=SaveCommand}"></Button>
                    <Button Content="Del" Command="{Binding Path=DeleteCommand}"></Button>
                </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <DockPanel DockPanel.Dock="Bottom" LastChildFill="False">
            <Button Content="Cancel Changes" DockPanel.Dock="Right" Command="{Binding Path=CancelChangesCommand}"/>
            <Button Content="Add New Item" DockPanel.Dock="Right" Command="{Binding Path=AddNewItemCommand}"/>
        </DockPanel>
    </DockPanel>
</Window>