Telerik Forums
UI for Silverlight Forum
3 answers
59 views

Hi,

 

I am using RadListBox for one of my project and are binding the data into the box using Observable collections but its take a long time to render the UI for around 500 items onto the UI.

Vladimir Stoyanov
Telerik team
 answered on 22 May 2019
13 answers
203 views
Hi,

I'm trying to create a grid that a user can use to reorder pictures.

To do that i've setup a RadListBox as follows:
<telerik:RadListBox
        Name="rlb"
           ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem,Mode=TwoWay}"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
           <telerik:RadListBox.DragVisualProvider>
               <telerik:ScreenshotDragVisualProvider />
           </telerik:RadListBox.DragVisualProvider>
           <telerik:RadListBox.DragDropBehavior>
               <telerik:ListBoxDragDropBehavior AllowReorder="True" />
           </telerik:RadListBox.DragDropBehavior>
           <telerik:RadListBox.ItemsPanel>
               <ItemsPanelTemplate>
                   <telerik:RadWrapPanel Orientation="Horizontal"/>
               </ItemsPanelTemplate>
           </telerik:RadListBox.ItemsPanel>
               <telerik:RadListBox.ItemTemplate>
               <DataTemplate>
                   <Border BorderThickness="2" BorderBrush="Red">
                       <Grid>
                           <Grid.RowDefinitions>
                               <RowDefinition Height="Auto"/>
                               <RowDefinition Height="Auto"/>
                           </Grid.RowDefinitions>
                           <TextBlock Text="{Binding Id}" Grid.Row="0"/>
                           <TextBlock Text="{Binding Value}" Grid.Row="1"/>
                       </Grid>
                   </Border>
               </DataTemplate>
           </telerik:RadListBox.ItemTemplate>
       </telerik:RadListBox>


With this i can reorder items in the listbox using drag n drop. However the dropvisual is not working as i would expect since it simply draws a horizontal line from left to right.

I tried creating a custom DropVisualProvider subclassing LinearDropVisualProvider and registering it with the listbox

    rlb.DropVisualProvider = new MyDropVisualProvider();

However none of the methods i override from LinearDropVisual are being called. I'm not sure what i am doing wrong at this point. What is the recommended way of specifying a custom IDropVisulaProvider?


Alexander
Top achievements
Rank 1
 answered on 30 Nov 2018
2 answers
53 views

Hi,

I created a custom item template (checkbox + textblock). The problem is there is small 2 pixels border which doesn't react to the click events.

Is there a way to eliminate that border or make it hit testable?

 

Thanks!

Tim
Top achievements
Rank 1
 answered on 14 Mar 2017
2 answers
105 views

When you Drag and drop an item onto itself it is creating a duplicate item in the listbox.  Is this expected behavior and if so is there a way to prevent it from creating the duplicate item.

 

We don't handle the ghost entry so it isn't a real problem just visually its been annoying our users.

Frank
Top achievements
Rank 1
 answered on 28 Nov 2016
4 answers
168 views
Hello,

The ItemContainerStyleSelector on the RadListBox is not working.

Here is what I did:

public class SpeakerStyleSelector : StyleSelector
    {
        public Style NoEmailSpeakerStyle { get; set; }
 
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (item is Speaker)
                return this.NoEmailSpeakerStyle;
 
            return null;
        }
    }
}



<Style x:Key="NoEmailSpeakerItemContainerStyle" TargetType="telerik:RadListBoxItem">
     <Setter Property="Foreground" Value="Red"/>
</Style>
         
<local:SpeakerStyleSelector x:Key="SpeakerItemContainerStyleSelector"
                    NoEmailSpeakerStyle="{StaticResource NoEmailSpeakerItemContainerStyle}"/>
 
 
...
 
 
<telerik:RadListBox   ItemsSource="{Binding Speakers}"
               ItemContainerStyleSelector="{StaticResource SpeakerItemContainerStyleSelector}" />

The SelectStyle method is never called.

BTW, if I set directly the NoEmailSpeakerItemContainerStyle with the ItemContainerStyle, it works fine!



Regards,
Adrien.
Kalin
Telerik team
 answered on 19 Apr 2016
1 answer
83 views

I have this xaml code:

                    <telerik:RadListBox x:Name="ActiveUnitList"

                                        ScrollViewer.VerticalScrollBarVisibility="Hidden"

                                        ItemsSource="{Binding MyUnits}"
                                        ItemTemplate="{StaticResource UnitTemplate}"
                                        SelectedItem="{Binding MyUnits.MySelectedUnit, Mode=TwoWay}" />

but the vertical scrollbar always shows up (even when the list of items fits in the listbox).  I've tried ...Visibility="Disabled" too but that didn't help.

How can I force the scrollbar to disappear?

-Thanks, Tom

Yana
Telerik team
 answered on 17 Mar 2016
4 answers
326 views
Attached is a simple project (actually no it's not because apparently I can't attach a zip file - the MainPage.xaml/xaml.cs are pasted below) with two RadListBoxes that have drag and drop enabled on them. Can someone please explain how I can prevent the items from being removed from their respective lists. That is I want to be able the reorder a list but not share the items between the two lists or any other control.

This is just a proof of concept, I have a 1 RadListBox in another project that I need to be able to reorder but I don't want users to be able to remove the items from the list. The RadListBox appears in a RadSplitButton drop down panel which happens to drop down over a RadGridView, I've set AllowDrop="false" on the grid but it hasn't help I can still drop the items from the list onto the Grid and then they just evaporate into the ether. Plus! I don't want to have to disable "Drop" on every other control to prevent a user removing the item from the list.


<UserControl x:Class="RadListBoxDragAndDropPOC.MainPage"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
        DataContext="{Binding RelativeSource={RelativeSource self}}"
        x:Name="Page">
 
 
    <UserControl.Resources>
        <Style x:Key="DraggableListBoxItem" TargetType="telerik:RadListBoxItem">
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
        </Style>
    </UserControl.Resources>
     
    <Grid x:Name="LayoutRoot">
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>
 
        <telerik:HeaderedContentControl Grid.Column="0">
 
                <telerik:RadListBox ItemsSource="{Binding Path=DataContext.MockDataList, ElementName=Page}"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ItemContainerStyle="{StaticResource DraggableListBoxItem}" AllowDrop="False">
                    <telerik:RadListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding DisplayName}" />
                            </StackPanel>
                        </DataTemplate>
                    </telerik:RadListBox.ItemTemplate>
                    <telerik:RadListBox.DragVisualProvider>
                        <telerik:ScreenshotDragVisualProvider />
                    </telerik:RadListBox.DragVisualProvider>
                    <telerik:RadListBox.DragDropBehavior>
                        <telerik:ListBoxDragDropBehavior AllowReorder="True" />
                    </telerik:RadListBox.DragDropBehavior>
                </telerik:RadListBox>
 
        </telerik:HeaderedContentControl>
 
        <telerik:HeaderedContentControl Grid.Column="1">
 
            <telerik:RadListBox ItemsSource="{Binding Path=DataContext.MockDataListTwo, ElementName=Page}"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ItemContainerStyle="{StaticResource DraggableListBoxItem}">
                <telerik:RadListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding DisplayName}" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadListBox.ItemTemplate>
                <telerik:RadListBox.DragVisualProvider>
                    <telerik:ScreenshotDragVisualProvider />
                </telerik:RadListBox.DragVisualProvider>
                <telerik:RadListBox.DragDropBehavior>
                    <telerik:ListBoxDragDropBehavior AllowReorder="True" />
                </telerik:RadListBox.DragDropBehavior>
            </telerik:RadListBox>
 
        </telerik:HeaderedContentControl>
 
 
    </Grid>
</UserControl>



using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
 
namespace RadListBoxDragAndDropPOC
{
    public partial class MainPage : UserControl
    {
 
 
        public ObservableCollection<MockData> MockDataList
        {
            get { return (ObservableCollection<MockData>)GetValue(MockDataListProperty); }
            set { SetValue(MockDataListProperty, value); }
        }
 
        // Using a DependencyProperty as the backing store for MockDataList.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MockDataListProperty =
            DependencyProperty.Register("MockDataList", typeof(ObservableCollection<MockData>), typeof(MainPage), new PropertyMetadata(null));
 
 
 
 
        public ObservableCollection<MockData> MockDataListTwo
        {
            get { return (ObservableCollection<MockData>)GetValue(MockDataListTwoProperty); }
            set { SetValue(MockDataListTwoProperty, value); }
        }
 
        // Using a DependencyProperty as the backing store for MockDataListTwo.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MockDataListTwoProperty =
            DependencyProperty.Register("MockDataListTwo", typeof(ObservableCollection<MockData>), typeof(MainPage), new PropertyMetadata(null));
 
 
        public MainPage()
        {
            InitializeComponent();
 
            List<MockData> mockDataList = new List<MockData>();
 
            mockDataList.Add(new MockData("One", 1));
            mockDataList.Add(new MockData("Two", 2));
            mockDataList.Add(new MockData("Three", 3));
            mockDataList.Add(new MockData("Four", 4));
            mockDataList.Add(new MockData("Five", 5));
            mockDataList.Add(new MockData("Six", 6));
            mockDataList.Add(new MockData("Seven", 7));
 
            this.MockDataList = new ObservableCollection<MockData>(mockDataList);
 
            List<MockData> mockDataList2 = new List<MockData>();
 
            mockDataList2.Add(new MockData("2One", 1));
            mockDataList2.Add(new MockData("2Two", 2));
            mockDataList2.Add(new MockData("2Three", 3));
            mockDataList2.Add(new MockData("2Four", 4));
            mockDataList2.Add(new MockData("2Five", 5));
            mockDataList2.Add(new MockData("2Six", 6));
            mockDataList2.Add(new MockData("2Seven", 7));
 
            this.MockDataListTwo = new ObservableCollection<MockData>(mockDataList2);
        }
    }
 
    public class MockData
    {
        public string DisplayName { get; set; }
        public int DisplayOrder { get; set; }
 
        public MockData(string displayName, int displayOrder)
        {
            this.DisplayName = displayName;
            this.DisplayOrder = displayOrder;
        }
    }
}
Terry
Top achievements
Rank 1
 answered on 10 Mar 2016
2 answers
145 views
I have a very simple ListBox populated by a list of strings. When it's enabled I can clearly see the selected items, however when I disable it (crude read-only mode). I can't see what has been selected, is there a way to still show selected items on a disabled ListBox? or a better way of making it Read-Only? 

Thanks,
Richard
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
 answered on 19 Oct 2015
1 answer
37 views
Using the windows ListBox, ctrl+click unselects items when SelectionMode=Single. Using the RadListBox, ctrl+click doesn't do anything when SelectionMode=Single. Is this functionality intentionally different for RadListBox? Is there a way to enable the ability to unselect items in a RadListBox when SelectionMode=Single (other than handling the mouse up event and manually unselecting the item)?
Nasko
Telerik team
 answered on 14 Oct 2015
2 answers
260 views
Hi,

I am having a listbox, which will disable and enable at runtime, I need to get the tooltip to be displayed for the listbox items, even when it is disabled. Currently tooltip is working only when the listbox is enabled. 

 ListBox x:Name="lstEpisod" ItemsSource="{Binding ScopeDetails,Mode=TwoWay}" Height="115" Width="212" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="#FFF3F3F3" ItemTemplate="{StaticResource EpisodeEncounterTemplate}" Margin="0,5,0,2" TabIndex="0" HorizontalAlignment="Left"> 
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem"> 
 <Setter Property="Padding" Value="0" /> 
 <Setter Property="Margin" Value="0"/> 
 <Setter Property="BorderThickness" Value="0"/> 
 <Setter Property="Background" Value="#FFF3F3F3"/> 
 <Setter Property="Foreground" Value="Black"/> 
</Style>
<!--<Setter Property="ToolTipService.ToolTip" Value="{Binding Text, RelativeSource={RelativeSource Self}}"/>--> 
</ListBox.ItemContainerStyle
</ListBox>

 
Thanks for any support.
Regards,
V.Chocks.

Nasko
Telerik team
 answered on 16 Jul 2015
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?