Telerik Forums
UI for WPF Forum
1 answer
108 views
i have scnerio like wherin i select a item from my listbox and depending upon the tag of the items i want to show different grids like if i select item1 and drag it then i should be able to see the product detail of that item in a radgridview in destination listbox.Would like to get asap as this is like a showstopper for our coming product.have added the xaml and the code behind file for the same.
<Window x:Class="DragandDrop.Window1"
    xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
   Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <DataTemplate x:Key="ApplicationDragTemplate">
             <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                </Grid.RowDefinitions>
                
                <TextBlock Text="{Binding Name}" Grid.Row="0"  VerticalAlignment="Top" />
                <TextBlock Text="{Binding Author}" Grid.Row="1"  VerticalAlignment="Top" />
  
                <!--<telerik:RadGridView x:Name="Info" Grid.Row="0" RowIndicatorVisibility="Collapsed" IsReadOnly="True"
                              ItemsSource="{Binding Path=ApplicationInfo}" ShowGroupPanel="False"
                                     AutoGenerateColumns="False">
  
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="110" HeaderTextAlignment="Center" TextAlignment="Left" Header="Name"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Author}" Width="80" HeaderTextAlignment="Center"  TextAlignment="Right"  Header="Author"/>
  
  
  
                </telerik:RadGridView.Columns>
  
            </telerik:RadGridView>-->
                  
            </Grid>
              
        </DataTemplate>
        <Style TargetType="ListBoxItem" x:Key="draggableItemStyle">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Foreground" Value="#000000" />
            <Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True" />
        </Style>
        </Window.Resources>
      
        <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="150" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <!--All Applications-->
        <telerikQuickStart:HeaderedContentControl Header="All Applications"
                  
                HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
            <ListBox x:Name="allApplicationsBox" Margin="3" BorderThickness="0"
                    telerik:RadDragAndDropManager.AllowDrop="True" Background="Transparent"
                    ItemContainerStyle="{StaticResource draggableItemStyle}"
                    >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="150">
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            
                            <TextBlock Grid.Row="1" Text="{Binding Name}" FontWeight="Bold"
                                    HorizontalAlignment="Center" />
                            <!--<TextBlock Text="{Binding Author}" Grid.Row="2"
                                    HorizontalAlignment="Center" />-->
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </telerikQuickStart:HeaderedContentControl>
        <!--Text-->
        <Border Grid.Column="1" Background="#1f2759" CornerRadius="5" VerticalAlignment="Center"
                HorizontalAlignment="Center">
          
        </Border>
        <!--My Applications-->
        <telerikQuickStart:HeaderedContentControl Header="My Applications"
                HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                Grid.Column="2">
            <ListBox x:Name="myApplicationsBox" Margin="3" Background="Transparent"
                    telerik:RadDragAndDropManager.AllowDrop="True" BorderThickness="0"
                    ItemContainerStyle="{StaticResource draggableItemStyle}"
                    >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel  VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0" Text="{Binding Name}" HorizontalAlignment="Center" />
                             <!--<TextBlock Text="{Binding Author}" HorizontalAlignment="Center" />-->
  
                            <telerik:RadGridView x:Name="View" Grid.Row="1" AllowDrop="True" RowIndicatorVisibility="Collapsed" IsReadOnly="True"
                              ItemsSource="{Binding Path=allApplications}" ShowGroupPanel="False"
                                     AutoGenerateColumns="False">
  
                                <telerik:RadGridView.Columns>
                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Width="110" HeaderTextAlignment="Center" TextAlignment="Left" Header="Name"/>
                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Author}" Width="80" HeaderTextAlignment="Center"  TextAlignment="Right"  Header="Author"/>
                                </telerik:RadGridView.Columns>
  
                            </telerik:RadGridView
                            </Grid>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <telerik:RadUniformGrid Columns="3" HorizontalAlignment="Left"
                                VerticalAlignment="Top" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </telerikQuickStart:HeaderedContentControl>
    </Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls.DragDrop;
  
namespace DragandDrop
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
  
        public static ObservableCollection<ApplicationInfo> GenerateApplicationInfos()
        {
            ObservableCollection<ApplicationInfo> result = new ObservableCollection<ApplicationInfo>();
  
            ApplicationInfo info1 = new ApplicationInfo();
            info1.Name = "James Collider";
            info1.Author = "Rockford";
            
            result.Add(info1);
  
            ApplicationInfo info2 = new ApplicationInfo();
            info2.Name = "Alentra";
            info2.Author = "Google.";
           
            result.Add(info2);
  
            ApplicationInfo info3 = new ApplicationInfo();
            info3.Name = "Thomas COOK";
            info3.Author = "Yahoo";
            
            result.Add(info3);
  
            ApplicationInfo info4 = new ApplicationInfo();
            info4.Name = "Britsh Airways";
            info4.Author = "Google";
          
  
            ApplicationInfo info5 = new ApplicationInfo();
            info5.Name = "Trader Joe";
            info5.Author = "Factory";
        
  
            ApplicationInfo info6 = new ApplicationInfo();
            info6.Name = "IE Fox";
            info6.Author = "Open Org";
           
            result.Add(info6);
  
            ApplicationInfo info7 = new ApplicationInfo();
            info7.Name = "Charting";
            info7.Author = "PieChart";
         
            result.Add(info7);
  
            ApplicationInfo info8 = new ApplicationInfo();
            info8.Name = "Batman";
            info8.Author = "Games";
        
            result.Add(info8);
  
            return result;
        }
  
        ObservableCollection<ApplicationInfo> allApplications = GenerateApplicationInfos();
        ObservableCollection<ApplicationInfo> myApplications;
        Brush listBoxDragPossible = new SolidColorBrush(Colors.Orange);
  
        public Window1()
        {
              
            InitializeComponent();
            myApplications = new ObservableCollection<ApplicationInfo>();
            allApplicationsBox.ItemsSource = allApplications;
            myApplicationsBox.ItemsSource = myApplications;
              
            RadDragAndDropManager.AddDragQueryHandler(this, OnDragQuery);
            RadDragAndDropManager.AddDragInfoHandler(this, OnDragInfo);
            RadDragAndDropManager.AddDropQueryHandler(this, OnDropQuery);
            RadDragAndDropManager.AddDropInfoHandler(this, OnDropInfo);
  
  
        }
  
        private void OnDropInfo(object sender, DragDropEventArgs e)
        {
            ItemsControl box = e.Options.Destination as ItemsControl;
            if (box == null) return;
            IList<ApplicationInfo> itemsSource = box.ItemsSource as IList<ApplicationInfo>;
            ApplicationInfo payload = e.Options.Payload as ApplicationInfo;
  
            if (e.Options.Status == DragStatus.DropPossible)
            {
                box.BorderBrush = listBoxDragPossible;
            }
            else
            {
                box.BorderBrush = new SolidColorBrush(Colors.Gray);
            }
  
            if (e.Options.Status == DragStatus.DropComplete)
            {
                if (!itemsSource.Contains(payload))
                {
                    itemsSource.Add(payload);
                }
            }
        }
  
        void OnDropQuery(object sender, DragDropQueryEventArgs e)
        {
            ItemsControl box = e.Options.Destination as ItemsControl;
            if (box == null) return;
            IList<ApplicationInfo> itemsSource = box.ItemsSource as IList<ApplicationInfo>;
            ApplicationInfo payload = e.Options.Payload as ApplicationInfo;
  
            e.QueryResult = payload != null && !itemsSource.Contains(payload);
        }
  
        void OnDragInfo(object sender, DragDropEventArgs e)
        {
            try
            {
                ListBoxItem listBoxItem = e.Options.Source as ListBoxItem;
                ListBox box = ItemsControl.ItemsControlFromItemContainer(listBoxItem) as ListBox;
                IList<ApplicationInfo> itemsSource = box.ItemsSource as IList<ApplicationInfo>;
                ApplicationInfo payload = e.Options.Payload as ApplicationInfo;
  
                if (e.Options.Status == DragStatus.DragComplete)
                {
                    if (payload != null && itemsSource.Contains(payload))
                    {
                        itemsSource.Remove(payload);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
  
        protected virtual void OnDragQuery(object sender, DragDropQueryEventArgs e)
        {
            ListBoxItem listBoxItem = e.Options.Source as ListBoxItem;
            ListBox box = ItemsControl.ItemsControlFromItemContainer(listBoxItem) as ListBox;
  
            if (e.Options.Status == DragStatus.DragQuery && box != null)
            {
                e.Options.Payload = box.SelectedItem;
                ContentControl cue = new ContentControl();
                cue.ContentTemplate = this.Resources["ApplicationDragTemplate"] as DataTemplate;
                cue.Content = box.SelectedItem;
                e.Options.DragCue = cue;
                e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
            }
  
            e.QueryResult = true;
        }
    }
  
    public class ApplicationInfo
    {
       // private Double _price;
        private String _name;
        private String _author;
  
         
  
        
  
        public String Name
        {
            get { return this._name; }
            set { this._name = value; }
        }
  
        public String Author
        {
            get { return this._author; }
            set { this._author = value; }
        }
    }
      
}
Tsvyatko
Telerik team
 answered on 01 Nov 2010
1 answer
96 views
Hello,
What would be the best way to bind a tileview to xml data using a HierarchicalDataTemplate?

Best Regards,
Rick
Miro Miroslavov
Telerik team
 answered on 01 Nov 2010
1 answer
55 views
when my chart datasource is nothing it gives me the error
"UIElement.Measure(availableSize) cannot be called with NaN size."
I am using this in dashboard
Waht should i do now to remove this error /


Thanks

Rakhi
Top achievements
Rank 1
 answered on 30 Oct 2010
1 answer
96 views
I have a tileview populated dynamically with a listbox in each tileitem. When a user makes a selection which ever listbox in that tile maximized. I tried to use the same logic as your demo, but it can't see the listbox.

Regards,
Rick
Tina Stancheva
Telerik team
 answered on 29 Oct 2010
2 answers
782 views
How do you get a RadGridView's columns to expand to fill all of the available space of the RadGridView? Right now they are the size of the content inside and no larger and aligned left. I would like them to size fill in some manner.
Ristogod
Top achievements
Rank 2
 answered on 29 Oct 2010
2 answers
237 views
I do not want to modify default behaviour of escape key. When pressing escape key it does cancel edit correctly. I wanted to handle that event to perform another/additional function. how is it possible?
M
Top achievements
Rank 1
 answered on 29 Oct 2010
3 answers
129 views
I have a GridView using a ObservableColletion source.

The cells are dynamically updated after the row is added.

I am looking for an event that occurs on a cell/row that has the data updated.

Any suggestions?

I have tried cellselector and propertychanged cant find it.

BTW there is no 'cellediting' occuring, just receiving of a propertychanged notify from the collection.
Thanks
Vlad
Telerik team
 answered on 29 Oct 2010
3 answers
105 views
Hello,
I am trying for the cell formatting on condition of child grid view but it can't.
I have use the template selector class. can u help me?
Vlad
Telerik team
 answered on 29 Oct 2010
1 answer
122 views
Does RadControls for WPF Q3 2010 beta version has RichTextBox Control? I have been waiting for it...

Thanks,
Iva Toteva
Telerik team
 answered on 29 Oct 2010
1 answer
141 views
Hi,

 I have a few docked panes and floating panes in my application at any given time. I wish to have a menu option for user to AutoHide All and Show All panes.
For docked panes, I Can set Is Pinned property, but how to hide/ show the floating pane.
Konstantina
Telerik team
 answered on 29 Oct 2010
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?