前提・実現したいこと
WPFでGUIアプリを制作しているのですが,Viewbox
内に配置したItemsControl
で,高さ方向はStretchしてくれますが,幅方向にStretchしてくれません.
該当のソースコード
今回の質問と関連なさそうなSliderのスタイルやConverterの詳細については割愛させていただきます.
Xaml
1 <GroupBox> 2 <GroupBox.Header> 3 <Label Content="グループボックス" FontSize="18" /> 4 </GroupBox.Header> 5 <Viewbox Stretch="Uniform"> 6 <ItemsControl ItemsSource="{Binding HogeCollection}" HorizontalContentAlignment="Stretch" 7 ItemTemplate="{StaticResource HogeItemLayout}"> 8 </ItemsControl> 9 </Viewbox> 10 </GroupBox> 11
Xaml
1 <DataTemplate x:Key="HogeItemLayout"> 2 <Grid> 3 <Grid.RowDefinitions> 4 <RowDefinition/> 5 <RowDefinition/> 6 </Grid.RowDefinitions> 7 <Grid.ColumnDefinitions> 8 <ColumnDefinition Width="*"/> 9 <ColumnDefinition Width="3*"/> 10 <ColumnDefinition Width="2*"/> 11 <ColumnDefinition Width="*"/> 12 </Grid.ColumnDefinitions> 13 14 <Viewbox Grid.Row="0" Grid.Column="0"> 15 <Label Content="{Binding Id}"/> 16 </Viewbox> 17 <Viewbox Grid.Row="0" Grid.Column="1"> 18 <Label HorizontalAlignment="Left" Content="{Binding Name}"/> 19 </Viewbox> 20 <Viewbox Grid.Row="0" Grid.Column="2"> 21 <Label HorizontalAlignment="Right" Content="{Binding CurrentNum, Converter={StaticResource ToStringConverter}}"/> 22 </Viewbox> 23 <Viewbox Grid.Row="0" Grid.Column="3"> 24 <Label Content="mm"/> 25 </Viewbox> 26 <Slider Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" 27 Style="{StaticResource CustomSliderStyle}" 28 Foreground="{DynamicResource CynBrush}" 29 Maximum="{Binding Total}" 30 Value="{Binding CurrentVolume}"> 31 </Slider> 32 </Grid> 33 </DataTemplate> 34
試したこと
調べてHorizontalContentAlignment
にStretch
を適用してみましたが,うまくいきませんでした....
あなたの回答
tips
プレビュー