WPF应用程序中的日历网格

时间:2019-03-09 20:42:22

标签: wpf xaml layout grid

我想使用Windows日历中的布局制作日历应用程序 {{0}}

我想知道我可以使用哪些控件在wpf应用程序中进行此布局。我正在考虑在此块中使用网格和文本块,但这不适用于多个网格单元。我需要日历中的事件可以在此网格中与多个单元格分开。 我该怎么做才能在WPF中实现相同的布局?

2 个答案:

答案 0 :(得分:1)

我认为您在Grid的布局上是正确的。 Grid是高度可定制的,应该可以满足您对多个单元共享的需求。尝试使用Grid.ColumnSpan属性。您应该正确设置ColumnDefinition才能正确使用它。

查看official documentation中的示例以获取更多详细信息。 这也来自官方网站:

<Grid VerticalAlignment="Top" HorizontalAlignment="Left" ShowGridLines="True" Width="250" Height="100">
      <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
        <ColumnDefinition />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
      </Grid.RowDefinitions>

      <TextBlock FontSize="20" FontWeight="Bold" Grid.ColumnSpan="3" Grid.Row="0">2005 Products Shipped</TextBlock>
      <TextBlock FontSize="12" FontWeight="Bold" Grid.Row="1" Grid.Column="0">Quarter 1</TextBlock>
      <TextBlock FontSize="12" FontWeight="Bold" Grid.Row="1" Grid.Column="1">Quarter 2</TextBlock>
      <TextBlock FontSize="12" FontWeight="Bold" Grid.Row="1" Grid.Column="2">Quarter 3</TextBlock>
      <TextBlock Grid.Row="2" Grid.Column="0">50000</TextBlock>
      <TextBlock Grid.Row="2" Grid.Column="1">100000</TextBlock>
      <TextBlock Grid.Row="2" Grid.Column="2">150000</TextBlock>
      <TextBlock FontSize="16" FontWeight="Bold" Grid.ColumnSpan="3" Grid.Row="3">Total Units: 300000</TextBlock>
    </Grid>

答案 1 :(得分:1)

如果有此要求,我会考虑购买telerik许可证。

看看这个https://www.codeproject.com/Articles/30329/Creating-an-Outlook-Calendar-using-WPF-Part-1

由于您似乎需要不到半小时的定位时间和一半的列宽,所以我不确定是否可以使用网格。可以很容易地在画布上定位和拖动。然后进行一些计算以检测重叠和“捕捉”到列。 将线条绘制到位图上。

约会可能应该是用户控件,而不只是文本块。