- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我制定了一个如下所示的自定义时间表并且它有效但现在我正在尝试添加事件/约会并且我无法弄清楚我的生活如何做到这一点。我希望能够单击日历上的其中一个按钮(日期),创建约会/事件,然后将事件的标题添加到为正确的网格单元(日期)创建的 txtblock(网格单元)在日历上。我无法弄清楚如何通过单击指定的按钮来访问某个网格单元。我不会为这段代码的编写方式感到自豪。我最初想要一个 MVVM,但现在可以用了。我不得不遇到的问题是每次我单击 < 或 > 按钮更改月份时,都会创建一个新月份并删除旧月份。所以一次只能制作一个月。请提供任何帮助。
wpf 的一部分:使用 ItemsControl
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Content="{Binding day}" Width="175" HorizontalAlignment="Stretch" VerticalAlignment="Top" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" Name="btnCalenderDate" Click="btnCalenderDate_Click" Loaded="btnCalenderDate_Loaded" Height="18" FontSize="10" FontWeight="Bold">
</Button>
<TextBlock OpacityMask="Black" Name="txtBlockdays" VerticalAlignment="Top" TextWrapping="Wrap">
</TextBlock>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<!-- ItemContainerStyle -->
<ItemsControl.ItemContainerStyle>
<Style >
<Setter Property="Grid.Column" Value="{Binding WeekDay}" />
<Setter Property="Grid.Row" Value="{Binding WeekNo}" />
</Style>
</ItemsControl.ItemContainerStyle>
制造压光机的类(class)。
public partial class SchedulePage : Page, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
MainWindow _parentForm;
Schedule sched = new Schedule();
DateTime date = DateTime.Now;
Event newevent;
public SchedulePage(MainWindow parentForm)
{
InitializeComponent();
_parentForm = parentForm;
DateTime date = DateTime.Now; //These couple of lines determine the current month to show on startup.
_numValue = date.Month;
_numYear = date.Year;
//int year = date.Year;
_nameofmonth = NumValue;
_nameofyear = NumYear;
lblcurrentdate.Content = date.Month + "/ " + date.Day + "/ " + date.Year;
makeCalender();
}
//The region below are properties that are passed in to makeCalender() when the DateRight and DateLeft buttons
// get clicked theses values change. The properties hold the month and the year. Everytime a user
// clicks forward or backward to the next month, these values equal to the selected current month & year.
// However, Everytime these values change a new calender is made and the old one is cleared(deleted).
#region
// properties
public void NotifyPropertyChanged(String info)
{
// if (PropertyChanged != null)
// {
PropertyChanged(this, new PropertyChangedEventArgs(info));
//}
}
private int _numValue;
public int NumValue
{
get { return _numValue; }
set
{
_numValue = value;
}
}
private int _numYear;
public int NumYear
{
get { return _numYear; }
set
{
_numYear = value;
}
}
private int _nameofmonth ;
public int NameofMonth
{
get
{
return this._nameofmonth;
}
set
{
if (value != this._nameofmonth)
{
this._nameofmonth = value;
NotifyPropertyChanged("NameofMonth");
} return;
}
}
private int _nameofyear;
public int NameofYear
{
get
{
return this._nameofyear;
}
set
{
if (value != this._nameofyear)
{
this._nameofyear = value;
NotifyPropertyChanged("NameofYear");
} return;
}
}
#endregion //end of properties
//void TheViewModel_PropertyChanged(object src, PropertyChangedEventArgs e)
/*
{
_parentForm.bindings.schedule.Clear();
_nameofmonth = NumValue;//comboMonth.SelectedIndex + 1;
_nameofyear = comboYear.SelectedIndex + 2011;
makeCalender();
} */
// makeCalender() is how the calender is created and how it determines the gridcell layout of each month.
public void makeCalender() {
var t = new List<Schedule>();
DateTime curr = DateTime.Now;
int[] m = new int[7];
DateTime newcurr = new DateTime(NameofYear, NameofMonth, 1);
var cal = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar;
var ms = cal.GetWeekOfYear(new DateTime(newcurr.Year, newcurr.Month, 1), System.Globalization.CalendarWeekRule.FirstDay, System.DayOfWeek.Sunday);
for (int k = 0; k < 7; k++)
{
for (var i = 1; newcurr.Month == NameofMonth; newcurr = newcurr.AddDays(1))
{
var month_week = (newcurr.Day / 7);
sched.MonthWeek = newcurr.GetWeekOfMonth().ToString();
sched.Month = newcurr.Month.ToString();
sched.Year = newcurr.Year.ToString();
sched.day = newcurr.Day.ToString();
sched.WeekOfYear = cal.GetWeekOfYear(newcurr, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString();
sched.dayofweek = newcurr.DayOfWeek.ToString();
t.Add(sched);
//Here is where the calender is created. By looping through all the days in the selected month it will find the weeknumber and day of the week -->
// that that particular date belongs to and place in the correct gridcell.
_parentForm.bindings.schedule.Add(new Schedule { WeekNo = newcurr.GetWeekOfMonth() - 1, WeekDay = (int)newcurr.DayOfWeek, day = newcurr.Day.ToString() });
lblDate.Content = getMonth(newcurr.Month) + " " + newcurr.Year; //getMonth() determines string format of current month displayed.
}
}
DataContext = _parentForm.bindings;
}
// btnDateRight_Click allows us to navigate forward to the next month, if current month is -->
// december then the current year is incremented and the month starts on january (NumValue = 01)
private void btnDateRight_Click(object sender, RoutedEventArgs e)
{
_parentForm.bindings.schedule.Clear();
if (NumValue >= 1 && NumValue < 12)
{
NumValue += 1;
_nameofmonth = NumValue;
} else
{
NumYear += 1;
_nameofyear = NumYear;
NumValue = 01;
_nameofmonth = NumValue;
}
makeCalender();
}
// btnDateLeft_Click allows us navigate backwards to a previous month
// if navigating back and the current month is january, then the year is deincremented the current month is -->
// set to December (NumValue = 12)
private void btnDateLeft_Click(object sender, RoutedEventArgs e)
{
_parentForm.bindings.schedule.Clear();
if (NumValue > 1 && NumValue <= 12)
{
NumValue -= 1;
_nameofmonth = NumValue;
}
else
{
NumYear -= 1;
_nameofyear = NumYear;
NumValue = 12;
_nameofmonth = NumValue;
}
makeCalender();
}
// btnCalenderDate_Click (as of 11/5/2011) will only return the current month, day, year in messagebox
// --> Problem is displaying an event on the textblock(gridcell) of the selected button(date). -->
// Example: If I click on the button 5 of november 2011(11/5/2011) I should be able to make an event
// and display the title of the event on that pictular gridcell of 11/5/2011.
private void btnCalenderDate_Click(object sender, RoutedEventArgs e)
{
Button b = e.Source as Button;
int day = Convert.ToInt32(b.Content);
MessageBox.Show(NumValue + "/" + b.Content + "/" + NumYear);
//b.Content = "123";
newevent = new Event(NumValue, day, NumYear);
newevent.Show();
}
//btnCalenderDate_Loaded will determine todays date and highlight the button.
private void btnCalenderDate_Loaded(object sender, RoutedEventArgs e) //Sets the current day on the calender
{
DateTime date = DateTime.Now;
Button today = e.Source as Button;
if (NumValue == date.Month && (String)today.Content == date.Day.ToString() && NumYear == date.Year)
{
today.Background = Brushes.Aqua;
}
}
最佳答案
我不太确定您要做什么,但您是否考虑过使用 DataGrid.HitTest Method这可能是更好的方法。您可以使用鼠标点作为 HitTest 参数,它会为您提供行和列。
关于c# - 为自定义日历 WPF 创建事件/约会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8022929/
我有一个跟踪到期日期的电子表格(excel 2003),我想知道是否有办法让这些到期日期在 Outlook 中创建约会(提醒)。到期日期位于电子表格的一个字段中,实体名称位于另一列中。理想情况下,我希
我搜索文档,但找不到获取今天日期的函数。我可能错过了一些相当明显的东西。 我只需要类似的东西 julia> today() 2014-06-25 julia> string(today()) "201
我需要将开始/结束时间下拉列表中的项目更改为相隔 5 分钟。似乎没有简单的方法来设置它,所以我正在尝试 VBA。 我可以让检查员在打开预约表格时进行检查: If Inspector.CurrentIt
我正在尝试获取共享日历的所有项目(我已关注 Glen Scales 的 EWS - Access All Shared Calendars),但它仅在“共享日历”(法语中的“Calendriers p
我需要当前约会。如果当前没有约会,则下一个甚至上一个约会。 我打算使用 Restrict 来限制约会集,然后根据 restrict 参数选择第一个或最后一个约会(例如,限制在当前时间之后结束的约会,或
我对 Python 还很陌生 - 所以请友善:)我有一个带有日期列的数据框。我使用 从 TXT 文件导入它 df1 = pd.read_csv('FileName.TXT', low_memory=F
已经创建了一个 outlook 约会做这样的事情; Microsoft.Office.Interop.Outlook.Application app = null; Microsoft.Offic
我编写了这段代码来查找指定时间范围内指定类别的所有约会的总持续时间: private readonly MAPIFolder _timing; private int CalculateTotalDu
Appointment.Id 属性或 Appointment.Id.UniqueId 真的是唯一的吗? 我有最简单的方法,使用 ExchangeService.FindAppointments 检索约
我必须调用或处理以更新日历中现有事件(我单击的事件)的事件或方法名称是什么。完整日历可以在这里找到http://arshaw.com/fullcalendar/ 最佳答案 初始化 FullCalend
我制定了一个如下所示的自定义时间表并且它有效但现在我正在尝试添加事件/约会并且我无法弄清楚我的生活如何做到这一点。我希望能够单击日历上的其中一个按钮(日期),创建约会/事件,然后将事件的标题添加到为正
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我有一个 iOS 应用程序,我需要能够从 Exchange 用户那里获取所有约会。任何人都可以指出我在这方面的好方向吗?这似乎是可能的,因为 iPhone 和其他应用程序/Outlook 可以做到这一
我正在尝试使用 Python win32com 库从 outlook(2013) 获取事件,我已经设法做到了这一点,但是我无法获得它们的状态(已接受、暂定、已拒绝)。当我当前的代码获取所有事件时,了解
我想读取某个日期之间某个用户的所有约会。并从他们那里获取有关内容、从何时到何时、它的颜色(类别)、如果不在办公室的话状态的信息。我没有找到有效的样本。你能给我看一个示例吗? 我使用的是 MS 的 wi
这里是 Java 8/Groovy 2.4.3/2015 A.D.。我需要编写一个将安装在台式机/笔记本电脑上的 Swing 应用程序,我想知道现代 Swing 应用程序开发人员在以下方面是什么样的:
我是 Ruby 的新手,正在尝试弄清楚为什么以下内容无法按预期工作: 2.2.1 :010 > user_date = Date.today => Sun, 31 May 2015 2.2.1 :0
我正在尝试添加 Appointments到我的 UWP 应用。 我已成功设置约会,但创建的约会 ID 结果为空,这意味着约会未创建。 以下是我的代码: public static Re
我目前正在开发一个利用 Microsoft Exchange WebServices 的应用程序,我对 Appointment.IsRecurring 属性和 Appointment.Appointm
想想看,我在使用 IE 时遇到了问题,希望有人能够提供帮助......我有一个网站,访问者可以在该网站上报名参加特定的 session ,然后我希望能够为他们选择的日历生成约会;选项包括 Gmail、
我是一名优秀的程序员,十分优秀!