RadListBox bound to RadDataFilter DragDrop

1 Answer 76 Views
DataFilter DragAndDrop ListBox
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Benedikt asked on 16 Nov 2021, 02:23 PM

Hi, 
I use two RadListboxes to allow users to order some things and save the ordered list.
I now want the user to filter the lists and tried the RadDataFilter. 
So I bound the Listboxes Itemsource to the RadFIlter.

The problem is, that now the Drag Dop doesnt work anymore.

Is there any way I can do both? Use the filter and the Drag Drop? Or do I have to program my own filter functionality?

Greetings Benedikt

 

<UserControl 
    x:Class="DispoTelerik2.ucMappenProduktionslinienPlanung"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:DispoTelerik2"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
    xmlns:mat="clr-namespace:Telerik.Windows.Controls.MaterialControls;assembly=Telerik.Windows.Controls"
    xmlns:dataFilter="clr-namespace:Telerik.Windows.Controls.Data.DataFilter;assembly=Telerik.Windows.Controls.Data"
    >
    <Grid
        Grid.IsSharedSizeScope="True"
        >
        <Grid.Resources>
            <local:FarbeGutSchlechtConverter x:Key="FarbeGutSchlechtConverter" />
            <Style x:Key="DraggableListBoxItem" TargetType="telerik:RadListBoxItem" BasedOn="{StaticResource RadListBoxItemStyle}">
                <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
            </Style>
            <DataTemplate x:Key="MappenTemplate">
                <Border
                    BorderThickness="1"
                    BorderBrush="{telerik:MaterialResource ResourceKey=ReadOnlyBorderBrush}"
                    >
                    <Grid
                        Margin="2"
                        >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="ssgMappeProduktionslinienPlanung1"/>
                            <ColumnDefinition SharedSizeGroup="ssgMappeProduktionslinienPlanung2"/>
                            <ColumnDefinition SharedSizeGroup="ssgMappeProduktionslinienPlanung3"/>
                        </Grid.ColumnDefinitions>
                        <iconPacks:PackIconMaterial 
                            Grid.Row="0"
                            Grid.Column="0"
                            HorizontalAlignment="Center"
                            Kind="AlphaSCircle" 
                            >
                            <iconPacks:PackIconMaterial.Foreground>
                                <SolidColorBrush
                                    Color="{Binding Gesägt, Converter={StaticResource FarbeGutSchlechtConverter}}"
                                    />
                            </iconPacks:PackIconMaterial.Foreground>
                        </iconPacks:PackIconMaterial>
                        <TextBlock
                            Grid.Row="1"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            HorizontalAlignment="Center"
                            FontWeight="Bold"
                            FontSize="{DynamicResource FontSizeM}"
                            Text="{Binding Mappe}"
                            Margin="5 2 0 2"
                            />
                        <TextBlock
                            Grid.Row="2"
                            Grid.Column="0"
                            HorizontalAlignment="Center"
                            FontWeight="Bold"
                            Text="{Binding ProduktTyp}"
                            Margin="5 2 3 2"
                            />
                        <TextBlock
                            Grid.Row="2"
                            Grid.Column="1"
                            HorizontalAlignment="Center"
                            Text="{Binding Zellen, StringFormat={}Zellen: {0:n0}}"
                            Margin="8 2 0 2"
                            />
                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="0"
                            HorizontalAlignment="Center"
                            Text="{Binding AufwandBAZ, StringFormat={}Aufwand BAZ: {0:n0}}"
                            Margin="10 2 3 2"
                            Visibility="{Binding Path=ProduktGruppeMöbel, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="1"
                            HorizontalAlignment="Center"
                            Text="{Binding Einzelteile, StringFormat={}Einzelteile: {0:n0}}"
                            Margin="8 2 0 2"
                            Visibility="{Binding Path=ProduktGruppeMöbel, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="1"
                            HorizontalAlignment="Center"
                            Text="{Binding TrennwändeEinzelteile, StringFormat={}Einzelteile: {0:n0}}"
                            Margin="8 2 0 2"
                            Visibility="{Binding Path=ProduktGruppeTrennwände, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                        <TextBlock
                            Grid.Row="4"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            HorizontalAlignment="Center"
                            FontWeight="Medium"
                            Text="{Binding Termin, StringFormat={}Plantermin: {0:dd.MM.yy}}"
                            Margin="5 2 0 2"
                            />
                        <TextBlock
                            Grid.Row="5"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            HorizontalAlignment="Center"
                            FontWeight="Medium"
                            Text="{Binding Endtermin, StringFormat={}Endtermin: {0:dd.MM.yy}}"
                            Margin="5 2 0 2"
                            />
                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="0"
                            HorizontalAlignment="Center"
                            Text="{Binding MöbelProduktausprägung}"
                            Margin="5 2 3 2"
                            Visibility="{Binding Path=ProduktGruppeMöbel, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="1"
                            HorizontalAlignment="Center"
                            Text="{Binding MöbelSchwierigkeit, StringFormat={}Schwierigkeit: {0}}"
                            Margin="8 2 0 2"
                            Visibility="{Binding Path=ProduktGruppeMöbel, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="0"
                            HorizontalAlignment="Center"
                            Text="{Binding TrennwändeAnlagenmerkmal}"
                            Margin="5 2 3 2"
                            Visibility="{Binding Path=ProduktGruppeTrennwände, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="1"
                            HorizontalAlignment="Center"
                            Text="{Binding TrennwändeProfilausbildung}"
                            Margin="8 2 0 2"
                            Visibility="{Binding Path=ProduktGruppeTrennwände, Converter={StaticResource VisibleIfTrueConverter}}"
                            />
                    </Grid>
                </Border>
            </DataTemplate>
            <!--<DataTemplate x:Key="ProduktTypFilterEditorTemplate">
                <telerik:RadComboBox 
                    SelectedValue="{Binding Value, Mode=TwoWay}"
                    ScrollViewer.CanContentScroll="False"
					MinWidth="100" />
            </DataTemplate>-->
            <!--<local:clsCustomEditorTemplateSelector x:Key="CustomEditorTemplateSelector">
                <local:clsCustomEditorTemplateSelector.EditorTemplateRules>
                    <local:EditorTemplateRule 
                        PropertyName="ProduktTyp"
						DataTemplate="{StaticResource ProduktTypFilterEditorTemplate}" 
                        />
                </local:clsCustomEditorTemplateSelector.EditorTemplateRules>
            </local:clsCustomEditorTemplateSelector>-->
            <local:RadFilterTypes x:Key="RadFilterTypes" />
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="100*"/>
        </Grid.RowDefinitions>
        <telerik:RadToolBar
            Grid.Row="0"
            VerticalAlignment="Top"
            >
            <telerik:RadComboBox
                ToolTip="Anzuzeigende Linie auswählen"
                ItemsSource="{Binding ProduktionslinienBereiche}"
                SelectedItem="{Binding selProduktionslinienBereich, Mode=TwoWay}"
                telerik:TextSearch.TextPath="Bezeichnung"
                EmptyText="Linie auswählen"
                ScrollViewer.CanContentScroll="False"
                DisplayMemberPath="Bezeichnung"      
                ClearSelectionButtonContent="Auswahl aufheben"
                ClearSelectionButtonVisibility="Visible"
                />
            <telerik:RadDropDownButton
                ToolTip="Anzuzeigenden Zeitraum auswählen"
                IsOpen="{Binding ZeitraumOpen, Mode=TwoWay}"
                >
                <telerik:RadDropDownButton.Content>
                    <StackPanel
                        Orientation="Horizontal"
                        >
                        <iconPacks:PackIconMaterial
                            Kind="CalendarMultiple"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Width="{DynamicResource FontSizeM}"
                            Height="{DynamicResource FontSizeM}"
                            Margin="0 0 5 0"
                            />
                        <TextBlock
                            Text="Zeitraum"
                            />
                    </StackPanel>
                </telerik:RadDropDownButton.Content>
                <telerik:RadDropDownButton.DropDownContent>
                    <StackPanel
                        Margin="8,5"
                        >
                        <telerik:RadDateTimePicker
                            ToolTip="Datum das angezeigt werden soll?"
                            HorizontalAlignment="Left"
                            InputMode="DatePicker"
                            SelectedValue="{Binding Datum, Mode=TwoWay}"
                            AllowParsingWithoutSeparator="True"
                            />
                        <Button
                            Name="btZeitraum"
                            Content="Anzeigen"
                            Margin="0 10 0 0"
                            FontWeight="Medium"
                            Command="{Binding AktualisierenCommand}"
                            >
                        </Button>
                    </StackPanel>
                </telerik:RadDropDownButton.DropDownContent>
            </telerik:RadDropDownButton>
            <Button
                Command="{Binding SpeichernCommand}"
                ToolTip="Tagesplanung Speichern"
                >
                <Button.Content>
                    <StackPanel
                        Orientation="Horizontal"
                        >
                        <iconPacks:PackIconMaterial
                            Kind="ContentSaveOutline"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Width="{DynamicResource FontSizeM}"
                            Height="{DynamicResource FontSizeM}"
                            Margin="0 0 5 0"
                            />
                        <TextBlock
                            Text="Speichern"
                            />
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button
                Command="{Binding HinzufügenCommand}"
                ToolTip="Nicht fällige Mappe in Pool hinzufügen"
                >
                <Button.Content>
                    <StackPanel
                        Orientation="Horizontal"
                        >
                        <iconPacks:PackIconMaterial
                            Kind="FolderDownload"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Width="{DynamicResource FontSizeM}"
                            Height="{DynamicResource FontSizeM}"
                            Margin="0 0 5 0"
                            />
                        <TextBlock
                            Text="Hinzufügen"
                            />
                    </StackPanel>
                </Button.Content>
            </Button>
        </telerik:RadToolBar>
        <Grid
            Grid.Row="1"
            >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="100*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock
                Grid.Row="0"
                Grid.Column="0"
                Text="Pool"
                HorizontalAlignment="Center"
                FontSize="{telerik:MaterialResource ResourceKey=FontSizeL}"
                Margin="5"
                />
            <telerik:RadDataFilter 
                x:Name="rdfMappen"
                Grid.Row="1"
                Grid.Column="0"
                Source="{Binding Mappen}"
                AutoGenerateItemPropertyDefinitions="False"
                >
                <telerik:RadDataFilter.ItemPropertyDefinitions>
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="ProduktTyp"
						PropertyType="{Binding String, Source={StaticResource RadFilterTypes}}"
						DisplayName="Produkt-Typ" 
                        />
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="Mappe"
						PropertyType="{Binding Int, Source={StaticResource RadFilterTypes}}"
						DisplayName="Mappe" 
                        />
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="Endtermin"
						PropertyType="{Binding DateTime, Source={StaticResource RadFilterTypes}}"
						DisplayName="Endtermin" 
                        />
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="Termin"
						PropertyType="{Binding DateTime, Source={StaticResource RadFilterTypes}}"
						DisplayName="Plantermin" 
                        />
                </telerik:RadDataFilter.ItemPropertyDefinitions>
            </telerik:RadDataFilter>
            <telerik:RadListBox
                x:Name="rlbMappen"
                Grid.Row="2"
                Grid.Column="0"
                AllowDrop="True"
                ItemsSource="{Binding FilteredSource, ElementName=rdfMappen}"
                ItemTemplate="{StaticResource MappenTemplate}"
                ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                MinWidth="200"
                Margin="5 0"
                >
                <telerik:RadListBox.DragVisualProvider>
                    <telerik:ScreenshotDragVisualProvider />
                </telerik:RadListBox.DragVisualProvider>
                <telerik:RadListBox.DragDropBehavior>
                    <telerik:ListBoxDragDropBehavior 
                        AllowReorder="False" 
                        telerik:TouchManager.DragStartTrigger="TapHoldAndMove"
                        />
                </telerik:RadListBox.DragDropBehavior>
            </telerik:RadListBox>
            <TextBlock
                Grid.Row="0"
                Grid.Column="1"
                Text="Planung"
                HorizontalAlignment="Center"
                FontSize="{telerik:MaterialResource ResourceKey=FontSizeL}"
                Margin="5"
                />
            <telerik:RadDataFilter 
                x:Name="rdfMappenGeordnet"
                Grid.Row="1"
                Grid.Column="1"
                Source="{Binding MappenGeordnet}"
                AutoGenerateItemPropertyDefinitions="False"
                >
                <telerik:RadDataFilter.ItemPropertyDefinitions>
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="ProduktTyp"
						PropertyType="{Binding String, Source={StaticResource RadFilterTypes}}"
						DisplayName="Produkt-Typ" 
                        />
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="Mappe"
						PropertyType="{Binding Int, Source={StaticResource RadFilterTypes}}"
						DisplayName="Mappe" 
                        />
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="Endtermin"
						PropertyType="{Binding DateTime, Source={StaticResource RadFilterTypes}}"
						DisplayName="Endtermin" 
                        />
                    <dataFilter:ItemPropertyDefinition 
                        PropertyName="Termin"
						PropertyType="{Binding DateTime, Source={StaticResource RadFilterTypes}}"
						DisplayName="Plantermin" 
                        />
                </telerik:RadDataFilter.ItemPropertyDefinitions>
            </telerik:RadDataFilter>
            <telerik:RadListBox
                x:Name="rlbMappenGeordnet"
                Grid.Row="2"
                Grid.Column="1"
                AllowDrop="True"
                ItemsSource="{Binding FilteredSource, ElementName=rdfMappenGeordnet}"
                ItemTemplate="{StaticResource MappenTemplate}"
                ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                MinWidth="200"
                Margin="5 0"
                >
                <telerik:RadListBox.DragVisualProvider>
                    <telerik:ScreenshotDragVisualProvider />
                </telerik:RadListBox.DragVisualProvider>
                <telerik:RadListBox.DragDropBehavior>
                    <telerik:ListBoxDragDropBehavior 
                        AllowReorder="True" 
                        telerik:TouchManager.DragStartTrigger="TapHoldAndMove"
                        />
                </telerik:RadListBox.DragDropBehavior>
            </telerik:RadListBox>
        </Grid>
    </Grid>
</UserControl>


1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 18 Nov 2021, 01:16 PM

Hello Benedikt,

This scenario is not supported by the default ListBoxDragDropBehavior. This is because the behavior works with the ItemsSource of the RadListBox control and the FilteredSource of RadDataFilter (which is DataItemCollection) doesn't allow runtime collection changes in the concrete setup. Also, it will be more accurate if the drag/drop work with the original source collection (the Source value of the RadDataFilter control).

To achieve your requirement I would suggest you to create a custom drag/drop behavior using DragDropManager, instead of the default ListBoxDragDropbehavior.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DataFilter DragAndDrop ListBox
Asked by
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or