Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Silverlight数据网格包装行_Silverlight_Datagrid - Fatal编程技术网

使用Silverlight数据网格包装行

使用Silverlight数据网格包装行,silverlight,datagrid,Silverlight,Datagrid,我正在尝试设置Silverlight数据网格的样式,以便网格中显示的内容能够包装。我希望每个网格行(和网格标题)由两行单元格组成,而不是一行。这使每一行都更高,但同时保持所有内容在屏幕上可见,而不必水平滚动以查看所有字段。以下图片有助于说明我的目标: (我没有足够的代表直接发布图像,但上面的链接将显示一个示例屏幕截图) 我看到的模板让我可以自定义不同单元格的样式,但我没有看到任何可以让我控制这些单元格如何在屏幕上并排显示的模板 您最好放弃datagrid,改用ListView,在ListVie

我正在尝试设置Silverlight数据网格的样式,以便网格中显示的内容能够包装。我希望每个网格行(和网格标题)由两行单元格组成,而不是一行。这使每一行都更高,但同时保持所有内容在屏幕上可见,而不必水平滚动以查看所有字段。以下图片有助于说明我的目标:

(我没有足够的代表直接发布图像,但上面的链接将显示一个示例屏幕截图)


我看到的模板让我可以自定义不同单元格的样式,但我没有看到任何可以让我控制这些单元格如何在屏幕上并排显示的模板

您最好放弃datagrid,改用ListView,在ListView中,您需要显示自己设计的用户控件。我为我构建的应用程序做了类似的事情

在ListView的XAML中,您需要设置ItemContainerStyle,并在其中显示自定义UserControl(您可以使用网格设置行/列及其跨度)。基本上是这样的:

<ListView 
      Name="_listView"
       Grid.Row="0" Grid.Column="0"
      SelectionMode="Single"   
      IsSynchronizedWithCurrentItem="True"
      SelectedItem="{Binding SelectedAgent, Mode=TwoWay}"
      ItemsSource="{Binding Agents, Mode=OneWay}" 
      GridViewColumnHeader.Click="ListView_Click"
      DependencyProperties:ListBoxClickCommand.ClickCommand="{Binding ShowAgentDetailsCommand}">
      <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="ListViewItem">
                <Border 
                  Name="_border"
                  Padding="2"
                  CornerRadius="5" 
                  SnapsToDevicePixels="true"
                  Background="Transparent">
                    <Controls:AgentStateControl></Controls:AgentStateControl>
                </Border>
                <ControlTemplate.Triggers>
                  <Trigger Property="IsSelected" Value="True">
                    <Setter TargetName="_border" Property="Background" Value="CornflowerBlue" />
                  </Trigger>
                </ControlTemplate.Triggers>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </ListView.ItemContainerStyle>


AgentStateControl是我的自定义控件,它有两行,第二行的列跨度更大。可以根据需要创建该控件

您最好放弃datagrid,改用ListView,在ListView中,您需要显示自己设计的用户控件。我为我构建的应用程序做了类似的事情

在ListView的XAML中,您需要设置ItemContainerStyle,并在其中显示自定义UserControl(您可以使用网格设置行/列及其跨度)。基本上是这样的:

<ListView 
      Name="_listView"
       Grid.Row="0" Grid.Column="0"
      SelectionMode="Single"   
      IsSynchronizedWithCurrentItem="True"
      SelectedItem="{Binding SelectedAgent, Mode=TwoWay}"
      ItemsSource="{Binding Agents, Mode=OneWay}" 
      GridViewColumnHeader.Click="ListView_Click"
      DependencyProperties:ListBoxClickCommand.ClickCommand="{Binding ShowAgentDetailsCommand}">
      <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="ListViewItem">
                <Border 
                  Name="_border"
                  Padding="2"
                  CornerRadius="5" 
                  SnapsToDevicePixels="true"
                  Background="Transparent">
                    <Controls:AgentStateControl></Controls:AgentStateControl>
                </Border>
                <ControlTemplate.Triggers>
                  <Trigger Property="IsSelected" Value="True">
                    <Setter TargetName="_border" Property="Background" Value="CornflowerBlue" />
                  </Trigger>
                </ControlTemplate.Triggers>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </ListView.ItemContainerStyle>


AgentStateControl是我的自定义控件,它有两行,第二行的列跨度更大。可以根据需要创建该控件

谢谢,我很确定网格不支持这种样式,但我只是想确定一下。谢谢,我很确定网格不支持这种样式,但我只是想确定一下。