2015-10-02 67 views
0

我已經做了谷歌搜索,許多人都說要刪除所有的高度/寬度/邊距屬性,但這似乎不適用於輸入二進制值和十進制值的文本框。現在,如果拖動窗口,所有內容都會相應地調整大小,但有時按鈕仍然會被切掉。在xaml/c#編碼中,文本框按鈕不斷切斷?

<Page 
    x:Class="App1.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:App1" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"> 

     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="2*"/> 
      <ColumnDefinition Width="2*"/> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="2*"/> 
      <RowDefinition Height="2*"/> 
      <RowDefinition Height="1*"/> 
      <RowDefinition Height="1*"/> 
      <RowDefinition Height="2*"/> 
      <RowDefinition Height="1*"/> 
      <RowDefinition Height="2*"/> 
     </Grid.RowDefinitions> 

     <TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="Binary to Decimal Converter" FontSize="25" FontFamily="Times New Roman" FontWeight="Bold" TextAlignment="Center" Grid.ColumnSpan="3" Grid.Column="1" Grid.Row="1"/> 
     <TextBox x:Name="binaryValue" Grid.Column="3" Grid.Row="3" TextWrapping="Wrap" Text="" BorderThickness="1" FontSize="20" TextChanged="binaryValue_TextChanged" FontFamily="Times New Roman" Padding="0" Margin="0,0,0,10"/> 
     <TextBox x:Name="decimalValue" Grid.Column="1" Grid.Row="3" TextWrapping="Wrap" Text="" BorderThickness="1" FontSize="20" FontFamily="Times New Roman" TextChanged="decimalValue_TextChanged" Padding="0" Margin="0,0,0,10"/> 
     <TextBlock x:Name="textBlockBin" TextWrapping="Wrap" Text="Binary Value:" Grid.Column="1" Grid.Row="2" TextAlignment="Center" FontFamily="Times New Roman" FontSize="16" Margin="0,0,0,14"/> 
     <TextBlock x:Name="textBlockDec" TextWrapping="Wrap" Text="Decimal Value:" Grid.Column="3" Grid.Row="2" TextAlignment="Center" FontFamily="Times New Roman" FontSize="16" Margin="0,0,0,14"/> 
     <Button x:Name="buttonConvert" Content="Convert!" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Column="2" Grid.Row="5"/> 

    </Grid> 
</Page> 
+0

嘗試刪除'ScrollViewer.Horizo​​ntalScrollBarVisibility =「Auto」',但將'vertical'保留 - 那有幫助嗎? – simonalexander2005

+0

@ simonalexander2005不行,文字欄框仍在切斷 –

回答

1

你的問題就來了,因爲你正在使用*(相對大小)爲您的列的高度和寬度。

因爲您的文本是固定大小,所以在這些情況下給列和行設置固定大小會更好。然後,您可以使用*作爲邊緣,以便圍繞文本進行縮放。可以使用Auto

例如:

<Grid.ColumnDefinitions> 
     <ColumnDefinition/> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition/> 
    </Grid.ColumnDefinitions> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

然後,您可以給該頁面的minwidthminheight防止其收縮比內容更小。