WPF的datagrid怎么设置第一列为固定样式,然后其他列直接用itemsource赋值

WPF的datagrid怎么设置第一列为固定样式,然后其他列直接用itemsource赋值?一般itemsource是直接赋给整个datagrid,那想要第一列不是itemsource的数据咋办

摇曳的蔷薇
浏览 781回答 1
1回答

繁花不似锦

第一列不绑定数据就可以了吧  <sdk:DataGrid.Columns>                              <sdk:DataGridTemplateColumn Header="操作">                            <sdk:DataGridTemplateColumn.CellTemplate >                                <DataTemplate>                                    <StackPanel Orientation="Horizontal">                                        <Button Content="删除" x:Name="btnDelete" Click="btnDelete_Click" Width="40" Height="20"></Button>                                        <Button Content="更新" x:Name="btnUpdate" Click="btnUpdate_Click" Width="40" Height="20"></Button>                                    </StackPanel>                                </DataTemplate>                            </sdk:DataGridTemplateColumn.CellTemplate>                        </sdk:DataGridTemplateColumn>                         <sdk:DataGridTemplateColumn Header="编号" Visibility="Collapsed" >                            <sdk:DataGridTemplateColumn.CellTemplate >                                <DataTemplate>                                    <TextBlock x:Name="id" Text="{Binding id}" ></TextBlock>                                </DataTemplate>                            </sdk:DataGridTemplateColumn.CellTemplate>                        </sdk:DataGridTemplateColumn>                                                                            </sdk:DataGrid.Columns>
打开App,查看更多内容
随时随地看视频慕课网APP