1

Windows Phone アプリのレイアウトに奇妙な問題があります。4列のグリッドがあります。それぞれの中に Border を配置し、これらの境界線を完全な正方形にしたいと思います (コンテナの高さが変わっても...)。

関連するコードは次のとおりです。

<Grid Grid.Row="1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="Red"  Height="{Binding Path=ActualWidth, RelativeSource={RelativeSource self}}"><TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" /></Border>
<Border Grid.Column="1" Background="Red" Height="{Binding Path=ActualWidth, RelativeSource={RelativeSource self}}"><TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" /></Border>
<Border Grid.Column="2" Background="Red" Height="{Binding Path=ActualWidth, RelativeSource={RelativeSource self}}"><TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" /></Border>
<Border Grid.Column="3" Background="Red" Height="{Binding Path=ActualWidth, RelativeSource={RelativeSource self}}"><TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" /></Border>

</Grid>

Blend で素晴らしいレンダリングを行います:

ここに画像の説明を入力

しかし、シミュレーターで実行すると、境界線がなくなります (高さが 0 になったように見えます)。

コードビハインドにコードはありません..

私の問題について誰か考えがありますか?

ありがとう、

4

1 に答える 1

1

ActualWidth/ActualHeightプロパティにバインドしようとしています。以前の質問(ここ)から、これはSilverlightの既知の問題であり、簡単な回避策はありません。

幅にバインドして列幅を指定するなど、他の方法を試してください。

   <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Border Grid.Column="0" Background="Red"  Width="100" Height="{Binding Path=Width, RelativeSource={RelativeSource self}}">
            <TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>
        <Border Grid.Column="1" Background="Red"  Width="100" Height="{Binding Path=Width, RelativeSource={RelativeSource self}}">
            <TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>
        <Border Grid.Column="2" Background="Red"  Width="100" Height="{Binding Path=Width, RelativeSource={RelativeSource self}}">
            <TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>
        <Border Grid.Column="3" Background="Red"  Width="100" Height="{Binding Path=Width, RelativeSource={RelativeSource self}}">
            <TextBlock Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>

    </Grid>
于 2013-01-23T10:31:24.833 に答える