如何将直线网格从当前单元格扩展到表格的下一个单元格

时间:2018-09-29 04:55:38

标签: c# wpf xaml data-binding datagridview

如何将直线网格从当前单元格扩展到表格的下一个单元格?实际在屏幕下方实现-

enter image description here

我想将第一个单元格中的蓝色网格扩展到第三个网格中,我很困惑地实现任何人都可以帮助我。

后端数据位于CSV文件中:以下是csv文件的一些示例-

SL,InstallTime,UninstalTime
10-1,1-Jun-2018, 3-jun-2018
10-2,2-Jun-2018,4-jun-2018
          ...

我的C#代码:读取csv数据,

    namespace WpfApp_sample
{
    class CsvGridData
    {
    }
    public static class CsvGridDataService
    {
        public static List<SampleGridItem> ReadFile(string filepath)
        {
            var lines = File.ReadAllLines(filepath);
            var random = new Random();
                var data = from l in lines.Skip(1)

                           let split = l.Split(',')

                           select new SampleGridItem
                           {
                               ProductionDate = DateTime.Parse(split[1]),

                               ProductName = split[0],
                               ProductionCount = Math.Abs(Convert.ToInt32(DateTime.Parse(split[2]).DayOfYear - DateTime.Parse(split[1]).DayOfYear))

                           };


                return data.ToList();
        }
    }
}

xaml代码:

<Window x:Class="WpfApp_sample.MainWindow"
        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:local="clr-namespace:APE.WPF.Controls.DynamicGrid;assembly=APE.WPF.Controls.DynamicGrid"
        mc:Ignorable="d"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <ScrollViewer CanContentScroll="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="465" Width="980" Canvas.Top="176">
            <ScrollViewer.Resources>
                <!-- Import the default style -->
                <ResourceDictionary Source="pack://application:,,,/APE.WPF.Controls.DynamicGrid;component/Sample/DynamicGridSampleControlDefaultStyle.xaml"/>
            </ScrollViewer.Resources>

            <local:DynamicGridSampleControl ItemWidth="100" ItemHeight="50" DataSource="{Binding GanttData}">

                <!-- ItemTemplate -->
                <local:DynamicGridSampleControl.DataItemTemplate>
                    <DataTemplate DataType="local:SampleGridItem">
                        <!-- Cell template -->
                        <Border Name="border" BorderBrush="#FF007F99" Margin="5" BorderThickness="0.1" CornerRadius="15,15,15,15">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="2,2" StartPoint="0.5,2">
                                    <GradientStop Color="#FF2FD9FD" Offset="2"/>
                                    <GradientStop Color="#FFCAF6FF" Offset="2"/>
                                    <GradientStop Color="#FF47D8F7" Offset="2"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid>
                                <TextBlock Text="{Binding ProductionCount}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Grid>
                        </Border>
                    </DataTemplate>
                </local:DynamicGridSampleControl.DataItemTemplate>

                <!-- HeaderTemplate -->
                <local:DynamicGridSampleControl.HeaderTemplate>
                    <DataTemplate>
                        <Grid Background="White">
                            <TextBlock Text="{Binding Path=., StringFormat=dd-MMM}" HorizontalAlignment="Center" VerticalAlignment="Center "/>
                        </Grid>
                    </DataTemplate>
                </local:DynamicGridSampleControl.HeaderTemplate>

                <!-- Wait layer template -->
                <local:DynamicGridSampleControl.WaitLayerTemplate>
                    <ControlTemplate>

                    </ControlTemplate>
                </local:DynamicGridSampleControl.WaitLayerTemplate>

            </local:DynamicGridSampleControl>
        </ScrollViewer>


    </Grid>
</Window>

0 个答案:

没有答案