Silverlight 4 ListBox(ListBoxItems)隐藏问题 [英] Silverlight 4 ListBox (ListBoxItems) hide Problem

查看:72
本文介绍了Silverlight 4 ListBox(ListBoxItems)隐藏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,
I have Silverlight 4 Application developed with the MVVM Pattern. I have also a PagedCollectionView bind on my Controls. The Items are Tasks that should be filtered in 4 categories (fill 4 different ListBoxes) impotent is that the filter is static. I have also another dynamic Filter for the user, that provides filtering by dates (day, week, month..).
So for the categories filter I use a Converter that set the visibilities of the ListboxItems to collapsed.
For the dynamic filter I user the PagedCollectionView filter possibilities.
The works also as expected, but there are empty spaces for the hiding Listboxitems and when the user goes with the Mouse over the empty space, he can mark the item. So the Items are not really hidden.
I use a WrapPanel for the Items.
So I know that cotrols are binding directly to the collection, but when I set the visibility to collapse  I expect that the items should hide.
Converter:
 public object Convert(object value, Type targetType, object parameter,
             System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                string prio = parameter as String;
                var v = value.ToString();

                if (prio != v) return Visibility.Collapsed;
            }

            return Visibility.Visible;
        }

Xaml:  <Style TargetType="ListBox" >
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                     <controlsToolkit:WrapPanel />
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter

        Property="ScrollViewer.HorizontalScrollBarVisibility"

        Value="Disabled"

        />

 <ListBox Name="ListBoxA" ItemsSource="{Binding Tasks}" Margin="0,15,0,0" Background="{StaticResource Background-Brush}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="80" Margin="1" Visibility="{Binding Path=Prio, ConverterParameter='A' ,Converter={StaticResource TaskFilter}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="2" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Rectangle  RadiusX="0" RadiusY="0" Grid.RowSpan="5" Grid.ColumnSpan="2" UseLayoutRounding="True">
                                <Rectangle.Fill>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,0">
                                        <!--<GradientStop Color="White" Offset="0" />-->
                                        <GradientStop Color="#FFEEFB08" Offset="4" />
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <TextBlock Name="NameField" Text="{Binding Path=Taskname}" Margin="4,2,2,2" Grid.Row="0" Grid.Column="1" FontWeight="Bold" FontSize="12" IsHitTestVisible="False" />

                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

I also tried to define the ListBoxItems but it doesn’t work.
I would be grateful for any help.
Thanks.
Martin

推荐答案

因此,没有解决我的问题的方法.控件要显示绑定中的所有项目.

在我的案例中,丑陋的工作方式是每个列表使用4个集合.

糟糕的想法是,每当原始集合发生更改时,这些集合就会刷新.
So, there is no solution for my problem. The controls want to show all items in the binding colleciton.

The ugly workarroung in my case is to use 4 collection for each list.

And the bad think is, that the collections are refreshad, every time when the orignal collection changes.


这篇关于Silverlight 4 ListBox(ListBoxItems)隐藏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆