Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
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
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900