日期:2014-05-17  浏览次数:20946 次

[咱也玩一玩]WPF立方体盒子承载DataGrid可旋转可平移可编辑
本帖最后由 lizhibin11 于 2012-07-18 23:06:24 编辑
最近在论坛看到几个WPF和XNA的三维问题,在尝试回答时研究了一下,现炒现卖,做了一个立方体盒子承载DataGrid,可以用方向键上下左右旋转,用鼠标滚轮前进后退,DataGrid可以编辑。

代码:
UserControl

<UserControl x:Class="WpfApplication2.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <DataGrid Grid.Row="1" Name="dataGrid1" RowBackground="Orange" ColumnWidth="*" />
        <DataGrid Grid.Column="1" Grid.Row="1"  Name="dataGrid2" RowBackground="Yellow" ColumnWidth="*" />
        <DataGrid Grid.Column="2" Grid.Row="1" Name="dataGrid3" RowBackground="Red" ColumnWidth="*" />
        <DataGrid Grid.Column="3" Grid.Row="1" Name="dataGrid4" RowBackground="Blue" ColumnWidth="*"  />