首页 > 解决方案 > Calendar grid in WPF application

问题描述

I want to make calendar application with layout like in windows calendar enter image description here

I wondering what controls can i use to do this layout in wpf application. I was thinking about grid and text blocks in this block but this doesn't work with multiple grid cell. I need my event in calendar can be split with multiple cell in this grid. What can I do to achieve the same layout in WPF?

标签: wpfxamllayoutgrid

解决方案


我认为您在Gridfor 布局方面处于正确的轨道。Grid是高度可定制的,应该支持您对多个单元共享的需求。试试Grid.ColumnSpan物业。您应该正确设置您的设备ColumnDefinition才能正确使用它。

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

<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>

推荐阅读