0

I have a handful of TextBlock's on my MainPage.xaml which have a subtle amount of distance between each other to look uniform. The last textbox however is larger and allows the text to be wrapped. The problem which I am facing is when I populate the textbox with a lot of content and all of the textblock's seem to stick to one another.

Image to explain:

enter image description here

The left image is fine, but as you can see on the right image, when I fill the box completely then all the textblock's magically stick together somehow.

Markup:

<ScrollViewer x:Name="LayoutRoot" Background="Transparent">
    <Grid>
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,635">
            <TextBlock Text="Project" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="Project" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Margin="12,161,12,0">

            <toolkit:ListPicker x:Name="myObj" ItemsSource="{Binding myobj, ElementName=this, Mode=OneTime}" Margin="12,12,12,537" >
                <toolkit:ListPicker.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Name, Mode=OneTime}" FontSize="{StaticResource PhoneFontSizeSmall}"/>
                            <TextBlock Text="{Binding Id, Mode=OneTime}" FontSize="{StaticResource PhoneFontSizeSmall}" Visibility="Collapsed"/>
                        </StackPanel>
                    </DataTemplate>
                </toolkit:ListPicker.ItemTemplate>
                <toolkit:ListPicker.FullModeItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Name, Mode=OneTime}" Padding="5" FontSize="{StaticResource PhoneFontSizeLarge}"/>
                            <TextBlock Text="{Binding Id, Mode=OneTime}" FontSize="{StaticResource PhoneFontSizeSmall}" Visibility="Collapsed"/>
                        </StackPanel>
                    </DataTemplate>
                </toolkit:ListPicker.FullModeItemTemplate>
            </toolkit:ListPicker>
            <toolkit:PhoneTextBox Height="auto" Name="txtName" Margin="0,70,0,456" Hint="Name" Text="{Binding Name, Mode=TwoWay}" LostFocus="TxtName_OnLostFocus"/>
            <toolkit:PhoneTextBox Height="auto" Name="txtAddress" Margin="0,138,0,388" Hint="First Line of Address" Text="{Binding Address, Mode=TwoWay}" LostFocus="TxtAddress_OnLostFocus"/>
            <toolkit:PhoneTextBox Height="auto" Name="txtEmail" Margin="0,206,0,320" Hint="Email Address" Text="{Binding Email, Mode=TwoWay}" LostFocus="TxtEmail_OnLostFocus"/>
            <toolkit:PhoneTextBox Height="auto" Name="txtTelephone" Margin="0,274,0,252" Hint="Telephone" Text="{Binding Telephone, Mode=TwoWay}" LostFocus="TxtTelephone_OnLostFocus"/>
            <toolkit:PhoneTextBox Height="auto" Name="txtComments" Margin="0,340,0,71" Hint="Comments" TextWrapping="Wrap"/>
        </Grid>
    </Grid>
</ScrollViewer>

Anyone see the obvious problem?

4

2 回答 2

1

我认为问题在于您的保证金。而且 XAML 也不高效。

为什么不直接将 Rows 添加到 Grid 并将每个 TextBox 放入其自己的行中 - 这将帮助您避免 HARDCODE 边距导致结果混乱......

或者另一种方法是将everuthing放入垂直堆栈面板

于 2013-10-01T07:02:05.720 回答
0

我通过在 TextBlocks 上替换Height="auto"为来解决了这个问题。Height="80"

于 2013-09-30T10:34:41.563 回答