Commit 7c0b46e
Changed files (4)
src
MVPtoMVVM.mvvm
src/MVPtoMVVM.mvvm/viewmodels/ToDoItemViewModel.cs
@@ -65,8 +65,11 @@ namespace MVPtoMVVM.mvvm.viewmodels
public DateTime DueDate
{
get { return dueDate; }
- set { dueDate = value;
+ set
+ {
+ dueDate = value;
updater.Update(x => x.DueDate);
+ updater.Update(x => x.ShowDueSoonAlert);
SaveCommand.Changed();
}
}
@@ -74,6 +77,13 @@ namespace MVPtoMVVM.mvvm.viewmodels
public IObservableCommand SaveCommand { get; set; }
public IObservableCommand DeleteCommand { get; set; }
public MainWindowViewModel Parent { get; set; }
+ public bool ShowDueSoonAlert
+ {
+ get
+ {
+ return DueDate <= DateTime.Today.AddDays(1);
+ }
+ }
public string this[string columnName]
{
src/MVPtoMVVM.mvvm/alert.png
Binary file
src/MVPtoMVVM.mvvm/MainWindow.xaml
@@ -4,7 +4,8 @@
Title="MainWindow" Height="350" Width="525">
<DockPanel LastChildFill="False">
<DockPanel.Resources>
- <Style x:Key="ValidationStyle" TargetType="Control">
+ <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
+ <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}" />
@@ -18,6 +19,7 @@
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
+ <Image Source="alert.png" Visibility="{Binding Path=ShowDueSoonAlert, Converter={StaticResource BooleanToVisibilityConverter}, 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>
src/MVPtoMVVM.mvvm/MVPtoMVVM.mvvm.csproj
@@ -111,6 +111,9 @@
<Name>MVPtoMVVM</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="alert.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.