English 中文(简体)
1. 在WPF/Silverlight ListBox无一或以下空间的项目之间添加空间
原标题:Add space between items in a WPF/Silverlight ListBox without space above first or below last

在WPFListBox中,对空间项目是否有标准/最佳途径,因此,在连续项目之间有空间,但不是在上个或以下。

对我来说,增加间隔的最明显办法是修改<条码>项目编号,将以上、以下或以上及以下每个项目列入其中。 当然,这意味着第一个和(或)最后一个项目或单一项目将存在空间。

我可以利用触发器挑选不同的模板,用于第一、最后的中间项目,但想知道,是否有比我所失踪的更简单的模板——似乎控制间隔是共同的要求。

感谢。

<>m>NOTE:我参加了世界森林论坛的工作,但认为在银星XAML.中,情况相似。

最佳回答

我要做的是,在清单Box控制模板上出现负差值,给数据Template/ItemContainerStyle留下同样的差值。 这使空间成为第一个项目和最后项目。 参看以下XAML。 我在数据图中设定了“Button”(ListBoxItem)本身的余地。

   <Windows.Resources> 
     <ControlTemplate x:Key="ListBoxControlTemplate1" TargetType="{x:Type ListBox}">
        <Grid Background="{TemplateBinding Background}">
            <ItemsPresenter Margin="0,-5"/>
        </Grid>
       </ControlTemplate>
   </Window.Resources>


  <ListBox HorizontalAlignment="Center" VerticalAlignment="Center" Template="{DynamicResource ListBoxControlTemplate1}" Background="#FFAB0000">
        <Button Content="Button" Width="88" Margin="0,5"/>
        <Button Content="Button" Width="88" Margin="0,5"/>
        <Button Content="Button" Width="88" Margin="0,5"/>
        <Button Content="Button" Width="88" Margin="0,5"/>
        <Button Content="Button" Width="88" Margin="0,5"/>
    </ListBox>
问题回答

页: 1 项目 财产。 在风格上,你只是选择一种不同的风格,即该项目是第一个、最后还是另一个。





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签