Home > Net >  WPF one day specified in the Calendar, change the background color
WPF one day specified in the Calendar, change the background color

Time:04-10

In WPF, I need to specify a calendar in one day change the background color, need how to operate? On April 1, 2021, for example, and then change the background color of the day, or add ICONS on this date

CodePudding user response:

 
XMLNS="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
XMLNS: x="http://schemas.microsoft.com/winfx/2006/xaml"
XMLNS: d="http://schemas.microsoft.com/expression/blend/2008"
XMLNS: MC="http://schemas.openxmlformats.org/markup-compatibility/2006"
XMLNS: local="CLR namespace: WpfApp1"
MC: Ignorable="d"
Title="MainWindow" Height="450" Width="800" & gt;



& lt; Grid>

<style TargetType="Calendar" & gt;
<style. Triggers>



</style>







 
Using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
Using System. The Timers;
Using System. Windows;
Using System. Windows. Controls;
Using System. Windows. The Data;
Using System. Windows. The Documents;
Using System. Windows. Input;
Using System. Windows. Media;
Using System. Windows. Media. Imaging;
Using System. Windows. Navigation;
Using System. Windows. Shapes;

The namespace WpfApp1
{
///& lt; Summary>
///MainWindow. Xaml interaction logic
///& lt;/summary>
Public partial class MainWindow: Window
{
Public MainWindow ()
{
InitializeComponent ();
}
}

Public class Ticker: INotifyPropertyChanged
{
Public Ticker ()
{
The Timer Timer=new Timer ();
The timer. The Interval=1000;//1 second updates
The timer. Elapsed +=timer_Elapsed;
The timer. The Start ();
}

Public string Now
{
The get
{
Console. WriteLine (DateTime. Now. ToString (" yyyy - MM - dd "));
Return a DateTime. Now. ToString (" yyyy - MM - dd ");
}
}

Void timer_Elapsed (object sender, ElapsedEventArgs e)
{
If (PropertyChanged!=null)
PropertyChanged (this, new PropertyChangedEventArgs (" Now "));
}

The public event PropertyChangedEventHandler PropertyChanged;
}
}


CodePudding user response:

refer to 7th floor Bzdr response:
 
XMLNS="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
XMLNS: x="http://schemas.microsoft.com/winfx/2006/xaml"
XMLNS: d="http://schemas.microsoft.com/expression/blend/2008"
XMLNS: MC="http://schemas.openxmlformats.org/markup-compatibility/2006"
XMLNS: local="CLR namespace: WpfApp1"
MC: Ignorable="d"
Title="MainWindow" Height="450" Width="800" & gt;





<style TargetType="Calendar" & gt;
<style. Triggers>



</style>







 
Using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
Using System. The Timers;
Using System. Windows;
Using System. Windows. Controls;
Using System. Windows. The Data;
Using System. Windows. The Documents;
Using System. Windows. Input;
Using System. Windows. Media;
Using System. Windows. Media. Imaging;
Using System. Windows. Navigation;
Using System. Windows. Shapes;

The namespace WpfApp1
{
///& lt; Summary>
///MainWindow. Xaml interaction logic
///& lt;/summary>
Public partial class MainWindow: Window
{
Public MainWindow ()
{
InitializeComponent ();
}
}

Public class Ticker: INotifyPropertyChanged
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related