首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按钮,录音机,被切断

按钮,录音机,被切断
EN

Stack Overflow用户
提问于 2013-08-06 17:40:52
回答 4查看 12.7K关注 0票数 9

我真的很困惑,为什么我的一些文本框和按钮被切断,谁能帮我解决这个问题吗?谢谢!!

XAML代码

代码语言:javascript
复制
<Grid>
        <TabControl>
            <TabItem Name="tabHome">
                <TabItem.Header>
                    <Label Content="Home" MouseLeftButtonDown="tabHome_Click"/>
                </TabItem.Header>
                <Grid>
                    <Button Content="Parse" Height="23" x:Name="btn_parse" Width="75" Click="buttonParse_Click" Margin="180,10,180,176"/>
                    <TextBox IsReadOnly="True"  x:Name="txtbox_filepath" Height="25" Width="135" Margin="151,52,150,132" />
                    <Button Content="Reset" Height="23" x:Name="btn_reset" Width="75" Margin="180,122,180,64" Click="buttonReset_Click"/>
                </Grid>
            </TabItem>
            <TabItem Name="tabConfig">
                <TabItem.Header>
                <Label Content="Configuration" MouseLeftButtonDown="tabConfig_Click"/>
                </TabItem.Header>
                <ScrollViewer>
                    <StackPanel Name="panelConfig">
                    </StackPanel>
                </ScrollViewer>
            </TabItem>
<Grid>

截图

如您所见,按钮和文本框在角处被切断。

谢谢你的帮助我很感激。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-08-06 17:47:16

当您给出像这个Margin="180,10,180,176"这样的保证金值时,这意味着控件必须从左到右分别放置180个dip和10个dip,从右边180个,从底部176个到父控件。由于保证金值高,您的控件被剪裁了。

注: dip设备独立像素.

最好为RowDefinitions创建Grid,并将控件放在具有合理边距值的单独行中,如下所示。

代码语言:javascript
复制
<Grid>
    <TabControl>
        <TabItem Name="tabHome">
            <TabItem.Header>
                <Label Content="Home"/>
            </TabItem.Header>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Button Grid.Row="0" Content="Parse" Height="23" x:Name="btn_parse" Width="75" Margin="10" />
                <TextBox Grid.Row="1" IsReadOnly="True"  x:Name="txtbox_filepath" Height="25" Width="135" Margin="10" />
                <Button Grid.Row="2" Content="Reset" Height="23" x:Name="btn_reset" Width="75" Margin="10"/>
            </Grid>
        </TabItem>
        <TabItem Name="tabConfig">
            <TabItem.Header>
                <Label Content="Configuration"/>
            </TabItem.Header>
            <ScrollViewer>
                <StackPanel Name="panelConfig">
                </StackPanel>
            </ScrollViewer>
        </TabItem>
    </TabControl>
</Grid>
票数 16
EN

Stack Overflow用户

发布于 2013-08-06 17:44:04

您正在为按钮显式设置HeightWidth,但您使用的值太小。

如果您将其关闭,则该按钮应正确显示:

代码语言:javascript
复制
<Button Content="Parse" x:Name="btn_parse" Click="buttonParse_Click" Margin="180,10,180,176"/>
<Button Content="Reset" x:Name="btn_reset" Margin="180,122,180,64" Click="buttonReset_Click"/>

请注意,如果您自己使用Grid或其他容器来设计布局,而不是使用Margin,那么您可以做得更好。

票数 3
EN

Stack Overflow用户

发布于 2013-08-06 17:43:31

删除HeightWidthMargin属性。

不要使用Visual设计器创建WPF UI。

看看http://wpftutorial.net/LayoutProperties.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18086895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档