0
Есть ли способ сделать Datagird с квадратными объектами вместо того, чтобы выглядеть как список?Wpf DataGrid Squares
что-то вроде этого:
Есть ли способ сделать Datagird с квадратными объектами вместо того, чтобы выглядеть как список?Wpf DataGrid Squares
что-то вроде этого:
вы имеете в виду Лик это ... он положил квадратную кнопку в каждой ячейке
<DataGrid SelectionUnit="Cell" ItemsSource="{Binding rows, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" x:Name="grid"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="257" Width="240"
Margin="10,10,0,0" AutoGenerateColumns="False" FrozenColumnCount="3" CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTemplateColumn Width="75">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button IsEnabled="{Binding DataContext.GameOver, Converter={StaticResource GameOverToEnabledConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Content="{Binding Cell1.State}" Command="{Binding DataContext.ButtonClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" CommandParameter="{Binding Cell1}" FontSize="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Height="75"></Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="75">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button IsEnabled="{Binding DataContext.GameOver, Converter={StaticResource GameOverToEnabledConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Content="{Binding Cell2.State}" Command="{Binding DataContext.ButtonClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" CommandParameter="{Binding Cell2}" FontSize="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Height="75"></Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="75">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button IsEnabled="{Binding DataContext.GameOver, Converter={StaticResource GameOverToEnabledConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Content="{Binding Cell3.State}" Command="{Binding DataContext.ButtonClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" CommandParameter="{Binding Cell3}" FontSize="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Height="75"></Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
вам придется ramove связывания рефов, чтобы заставить его работать ... Это было частью более крупного проекта здесь Insert Rows in WPF