网格内相同大小的Kinect圆形按钮

时间:2013-09-16 15:16:46

标签: c# .net wpf xaml kinect

我正在使用Kinect SDK KinectCircleButton开发WPF接口。 特别是,我必须使用可变数量的KinectCircleButton动态填充网格。 问题在于,由于按钮的标签长度​​可变,因此按钮可以呈现不同的尺寸,调整其尺寸以填充可用空间。我不能使用绝对定位或大小,因此属性“width”和“height”设置为“auto”。 我只想使文本适应可用空间(缩放或将其分成两行),但同时每个圆圈的大小相同。

为了清楚起见,我附上了当前GUI的屏幕截图: myGUI

使用以下XAML代码定义:

<Grid Grid.Column="1" Name="ButtonsGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="33*" />
                <ColumnDefinition Width="33*" />
                <ColumnDefinition Width="33*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="50*"/>
                <RowDefinition Height="50*"/>
            </Grid.RowDefinitions>

            <k:KinectCircleButton Name="CategoryButton1" Margin="10" Foreground="{x:Static c:Constants.TEXT_COLOR}" Width="auto" Height="auto" Grid.Column="0" Grid.Row="0" FontFamily="SansSerif" FontSize="48" FontWeight="SemiBold"/>
            <k:KinectCircleButton Name="CategoryButton2" Margin="10" Foreground="{x:Static c:Constants.TEXT_COLOR}" Width="auto" Height="auto" Grid.Column="1" Grid.Row="0" FontFamily="SansSerif" FontSize="48" FontWeight="SemiBold"/>
            <k:KinectCircleButton Name="CategoryButton3" Margin="10" Foreground="{x:Static c:Constants.TEXT_COLOR}" Width="auto" Height="auto" Grid.Column="2" Grid.Row="0" FontFamily="SansSerif" FontSize="48" FontWeight="SemiBold"/>
            <k:KinectCircleButton Name="CategoryButton4" Margin="10" Foreground="{x:Static c:Constants.TEXT_COLOR}" Width="auto" Height="auto" Grid.Column="0" Grid.Row="1" FontFamily="SansSerif" FontSize="48" FontWeight="SemiBold"/>
            <k:KinectCircleButton Name="CategoryButton5" Margin="10" Foreground="{x:Static c:Constants.TEXT_COLOR}" Width="auto" Height="auto" Grid.Column="1" Grid.Row="1" FontFamily="SansSerif" FontSize="48" FontWeight="SemiBold"/>
            <k:KinectCircleButton Name="CategoryButton6" Margin="10" Foreground="{x:Static c:Constants.TEXT_COLOR}" Width="auto" Height="auto" Grid.Column="2" Grid.Row="1" FontFamily="SansSerif" FontSize="48" FontWeight="SemiBold"/>
        </Grid>

如您所见,第一个按钮比其他按钮大,因此目标是为所有按钮设置相同的尺寸。

0 个答案:

没有答案