最初に、xaml コードがあります。
<Grid.Resources>
<DataTemplate x:Name="dataTemp" x:Key="dtKey">
<WrapPanel Orientation="Horizontal" Name="mainWP">
<TextBlock Name="codeTB" FontSize="18" Width="200" Text="{Binding barcode}"></TextBlock>
(...)
</WrapPanel>
</DataTemplate>
</Grid.Resources>
およびデータテンプレートを使用したリストビュー:
<ListView Name="testLV" Grid.Row="0" ItemTemplate="{StaticResource ResourceKey=dtKey}" >
</ListView>
したがって、コード ビハインドでは、TextBlock の幅を this.width/5 に変更したいと思います (別の PC では幅が異なる可能性があるため) が、DataTemplate であるため、このコントロールにアクセスできません。Width="{Binding Path=ActualWidth, ElementName=grid0}" も試しましたが、実際の幅として ActualWidth/5 のようなものが必要ですが、うまくいきません
ありがとう