0

FlipView画像と画像に関するテキストで構成されるコントロールウィッチがあります。テキストを画像と同じ幅にしたい。一部の画像は、他の画像とは寸法が異なります。
ここに私のXAMLコードがあります:

<FlipView x:Name="flipView"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" ItemsSource="{Binding ImagesWithDescriptions}">
    <FlipView.ItemTemplate>
        <DataTemplate>
            <Grid x:Name="grid" Tapped="flipView_Tapped">
                <Grid.RowDefinitions>
                    <RowDefinition Height="3*"/>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Image x:Name="image" Grid.RowSpan="2" Source="{Binding Image}"></Image>
                <Grid x:Name="textGrid" Grid.Row="1">
                    <Grid.Background>
                        <SolidColorBrush Color="Black" Opacity="0.5"/>
                    </Grid.Background>
                    <TextBlock Foreground="White" HorizontalAlignment="Left" FontSize="20" Text="{Binding Description}"/>
                </Grid>
            </Grid>
        </DataTemplate>
    </FlipView.ItemTemplate>
</FlipViewControl>

テキストを画像にバインドしようとするとActualWidth、常に 0 が返されます。それを行う方法はありますか?

編集:
次のようになります。

(--------------------FlipView の幅----------------------)
-------------------------------------------------- ------F
| | |これは画像です。高さは | |l
| | |FlipView の高さに等しい | |私
| | |ただし、幅は画像によって異なります| |p
| | |比は異なる場合があります | |V
| | |いくつかの写真。| | |私
| | | | | | |e
| | | | | | |w
| | | | | | | |
| | | | | | |時間
| | | | | | |e
|---------|----------------------------------|------- -----|私
|これは |「textGrid」という名前のグリッドが|現在ある場所です (|g です)
|幅は |FlipView のものと同じです) | |時間
-------------------------------------------------- ------t

Gridしかし、 「textGrid」という名前を Image と同じ幅にしたいのです。
バインド<Grid x:Name="textGrid" Width="{Binding ElementName=image, Path=ActualWidth}"/>すると、Gridの幅が常に 0 になります。Image Loaded イベントもActualWidth0 として返されます。

4

1 に答える 1