十八、平铺+将ListBoxitem的宽度设定为ListBox的三分之一

Silverlight 怎么把图片平铺?

1<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Horizontal">
           
        </StackPanel>


 2           <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <controlsToolkit:WrapPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>

如何将ListBoxitem的宽度设定为ListBox的三分之一? 我已经写了一个Converter,可是在XAML中如何写呢 总也运行不对,请教各位大大

里面加一个Grid 然后按比例 分为三列 让Item在 Grid.Row =2;

<ListBox> <ListBox.ItemTemplate> <DataTemplate> .....</DataTemplate> </ListBox.ItemTemplate>            <ListBox.ItemsPanel>                 <ItemsPanelTemplate>                     <controlsToolkit:WrapPanel Orientation="Horizontal"/>                 </ItemsPanelTemplate>             </ListBox.ItemsPanel>             <ListBox.ItemContainerStyle>                 <Style TargetType="ListBoxItem">                     <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox, AncestorLevel=1}, Path=Width, Converter={StaticResource WidthConverter}, ConverterParameter=4}"/>                 </Style>             </ListBox.ItemContainerStyle>             <!--<i:Interaction.Behaviors>                 <Behaviors:SynchronizeSelectedItems Selections="{Binding SelectedOption}"/>             </i:Interaction.Behaviors>-->

        </ListBox>

不能使用固定列数,因为是需要根据不同的情况,设定为2,3,4列的

那 你的 1/3如何取呢 :给Converter传一个参数

转载于:https://www.cnblogs.com/suinuaner/archive/2013/01/06/pingpu.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值