当GroupBox调整大小

时间:2015-12-14 10:29:59

标签: wpf xaml binding

GroupBox具有自动列宽。我不能再想到为什么在调整GroupBox大小时不会触发WidthConverter。任何替代品? 目标是始终显示5行和5列。当用户调整窗口大小时,列宽也必须调整大小。 TIA!

<GroupBox Grid.Column="0" Grid.ColumnSpan="7" Grid.Row="10" x:Name="GbSerial"
        Template="{StaticResource GbSerialProgrammed}">
        <GroupBox.Header>
            <TextBlock TextDecorations="Underline" FontWeight="Bold" FontSize="24" HorizontalAlignment="Center" TextAlignment="Center"
                Text="{lgg:Lgg Path=AllSerialNumberProgrammed}"/>
        </GroupBox.Header>
        <ScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">
            <ItemsControl x:Name="IcSerialNumbers" Background="White"  Tag="{Binding ElementName=GbSerial, Path=ActualWidth}"
                ItemsSource="{Binding AllSerialNumberProgrammed, UpdateSourceTrigger=PropertyChanged}"  
                helper:ItemsControlHelper.ScrollToLastItem="True"
                FontSize="24" Height="250" >
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="ContentPresenter">
                        <Setter Property="HorizontalAlignment" Value="Stretch" />
                        <Setter Property="Height" Value="50"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Width" Value="{Binding ElementName=GbSerial, 
                                    Path=ActualWidth, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True,
                                    Mode=OneTime, Converter={StaticResource WidthConverter}, 
                                    ConverterParameter=5}"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel IsItemsHost="True" FlowDirection="LeftToRight" Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl >
        </ScrollViewer>
    </GroupBox>

1 个答案:

答案 0 :(得分:1)

模式OneTime,顾名思义,意味着它只在启动时调用一次。