0

我意识到 Outlook 就像调度程序。我以:http: //www.codeproject.com/Articles/30881/Creating-an-Outlook-Calendar-Using-WPF-Part-2为基础,但我的日历应该有一些列用于显示数据用户。当然,我可以通过 XAML 添加一些用户的列,但这是静态解决方案,我不知道我的程序会显示多少用户。

如何改进此程序以添加用户的动态计数,或者可能有其他一些开源 WPF 控件用于它?

XAML 的 Calendar 样式代码,在接下来创建 3 个静态列:

 <Style TargetType="{x:Type local:Calendar}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Calendar}">
                    <Border Background="#E3EFFF"
                            BorderBrush="#6593CF"
                            BorderThickness="2,2,2,2">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="38" />
                                <RowDefinition Height="22" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>

                            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,0,0">
                                <Button Content="ToPreviousDay" Height="25" Command="{x:Static local:Calendar.PreviousDay}" Background="{x:Null}" BorderBrush="{x:Null}">

                                </Button>
                                <Button Content="ToNextDay" Height="25" Command="{x:Static local:Calendar.NextDay}" Background="{x:Null}" BorderBrush="{x:Null}">

                                </Button>
                            </StackPanel>
                            <Border BorderBrush="#6593CF" BorderThickness="0,0,1,1" Grid.Column="0" Grid.Row="1" />
                            <local:CalendarDayHeader Grid.Column="1" Grid.Row="1" x:Name="PART_DayHeader"/>
                            <ScrollViewer Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                                          ScrollViewer.VerticalScrollBarVisibility="Visible" x:Name="PART_ScrollViewer">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="50" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>




                                    <local:CalendarLedger Grid.Column="0" x:Name="PART_Ledger" Margin="0,25,0,0"/>

                                    <StackPanel Orientation="Horizontal" Grid.Column="1">
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>

                                            <Label Grid.Row="0" Content="User1_Column" x:Name="PART_Label"/>
                                                <local:CalendarDay Grid.Row="1" x:Name="PART_Day" />
                                        </Grid>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>

                                            <Label Grid.Row="0" Content="User2_Column" x:Name="PART_Label2"/>
                                            <local:CalendarDay Grid.Row="1" x:Name="PART_Day2" />
                                        </Grid>
                                        <Grid Width>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>

                                            <Label Grid.Row="0" Content="User3_Column" x:Name="PART_Label3"/>
                                            <local:CalendarDay Grid.Row="1" x:Name="PART_Day3" />
                                        </Grid>
                                    </StackPanel>
                                </Grid>
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

我想动态添加用户的列

4

0 回答 0