Telerik Forums
UI for WPF Forum
1 answer
157 views

Hi,

in my application, I'm using Telerik theme "Office_BlueTheme" and the control HeaderedContentControl doesn't seem to be affected by the theme I choose, I mean, the header of the control stay gray instead of having a kind of blue like other Telerik controls I used.

Thank's

Boyan
Telerik team
 answered on 25 Oct 2011
1 answer
124 views
Right, I have a list box to the left, and a schedule view to the right. On the schedule view I have included resources, by which I group. When I drag from the list to the schedule view, I can only drop onto the first group. When I attempt to drag an appointment already on the schedule view to another group on the schedule view, it won't allow it.

I have implemented a custom drag drop behaviour class:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.DragDrop;
using Telerik.Windows.Controls.ScheduleView;
 
namespace WpfApplication3
{
	public class ListBoxDragDropBehavior : Freezable
	{
		public static readonly DependencyProperty AppointmentTemplateProperty =
			DependencyProperty.Register("AppointmentTemplate"typeof(DataTemplate), typeof(ListBoxDragDropBehavior), null);
 
		public static readonly DependencyProperty EffectivePixelLengthProperty =
			DependencyProperty.Register("EffectivePixelLength"typeof(TimeSpan), typeof(ListBoxDragDropBehavior), null);
 
		public static readonly DependencyProperty EffectiveOrientationProperty =
			DependencyProperty.Register("EffectiveOrientation"typeof(Orientation), typeof(ListBoxDragDropBehavior), null);
 
		public static readonly DependencyProperty BehaviorProperty =
			DependencyProperty.RegisterAttached("Behavior"typeof(ListBoxDragDropBehavior), typeof(ListBoxDragDropBehavior), new PropertyMetadata(new PropertyChangedCallback(OnBehaviorChanged)));
 
		public DataTemplate AppointmentTemplate
		{
			get { return (DataTemplate)GetValue(AppointmentTemplateProperty); }
			set { SetValue(AppointmentTemplateProperty, value); }
		}
 
		public TimeSpan EffectivePixelLength
		{
			get { return (TimeSpan)GetValue(EffectivePixelLengthProperty); }
			set { SetValue(EffectivePixelLengthProperty, value); }
		}
 
		public Orientation EffectiveOrientation
		{
			get { return (Orientation)GetValue(EffectiveOrientationProperty); }
			set { SetValue(EffectiveOrientationProperty, value); }
		}
        
		public static ListBoxDragDropBehavior GetBehavior(DependencyObject obj)
		{
			return (ListBoxDragDropBehavior)obj.GetValue(BehaviorProperty);
		}
 
		public static void SetBehavior(DependencyObject obj, ListBoxDragDropBehavior value)
		{
			obj.SetValue(BehaviorProperty, value);
		}
 
		protected override Freezable CreateInstanceCore()
		{
			return new ListBoxDragDropBehavior();
		}
 
		private static void OnBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			System.Windows.Controls.ListBox listBox = d as System.Windows.Controls.ListBox;
			if (listBox == null)
			{
				return;
			}
 
			ListBoxDragDropBehavior behavior = (ListBoxDragDropBehavior)e.OldValue;
			if (behavior != null)
			{
				RadDragAndDropManager.RemoveDragQueryHandler(listBox, new EventHandler<DragDropQueryEventArgs>(behavior.OnDragQuery));
				RadDragAndDropManager.RemoveDropQueryHandler(listBox, new EventHandler<DragDropQueryEventArgs>(behavior.OnDropQuery));
				RadDragAndDropManager.RemoveDropInfoHandler(listBox, new EventHandler<DragDropEventArgs>(behavior.OnDropInfo));
			}
 
			behavior = (ListBoxDragDropBehavior)e.NewValue;
			if (behavior != null)
			{
				RadDragAndDropManager.SetAllowDrop(listBox, true);
				RadDragAndDropManager.AddDragQueryHandler(listBox, new EventHandler<DragDropQueryEventArgs>(behavior.OnDragQuery));
				RadDragAndDropManager.AddDropQueryHandler(listBox, new EventHandler<DragDropQueryEventArgs>(behavior.OnDropQuery));
				RadDragAndDropManager.AddDropInfoHandler(listBox, new EventHandler<DragDropEventArgs>(behavior.OnDropInfo));
			}
		}
 
		private void OnDragQuery(object sender, DragDropQueryEventArgs e)
		{
			if (e.Options.Status == DragStatus.DragQuery)
			{
				System.Windows.Controls.ListBox listbox = sender as System.Windows.Controls.ListBox;
 
				IList<IOccurrence> appointments = listbox.SelectedItems.OfType<IOccurrence>().ToList();
 
				if (appointments.Count == 0)
				{
					return;
				}
 
				e.Options.DragCue = this.CreateDragCue(appointments);
				e.Options.Payload = new ScheduleViewDragDropPayload(listbox.ItemsSource, appointments);
			}
 
			e.QueryResult = true;
		}
 
		private void OnDropQuery(object sender, DragDropQueryEventArgs e)
		{
			e.QueryResult = e.Options.Payload is ScheduleViewDragDropPayload;
		}
 
		private void OnDropInfo(object sender, DragDropEventArgs e)
		{
            System.Windows.Controls.ListBox listBox = sender as System.Windows.Controls.ListBox;
 
			if (e.Options.Status == DragStatus.DropPossible)
			{
				RadDragAndDropManager.Options.Effects = DragDropEffects.All;
				RadDragAndDropManager.Options.CurrentCursor = System.Windows.Input.Cursors.Arrow;
			}
 
            //If the user has dropped - and the drag was made FROM the scheduleview TO the listbox
			if (e.Options.Status == DragStatus.DropComplete && !listBox.IsAncestorOf(e.Options.Source))
			{
				ScheduleViewDragDropPayload payload = e.Options.Payload as ScheduleViewDragDropPayload;
				if (payload != null)
				{
					(payload.SourceAppointmentsSource as IList).RemoveAll((object i) => payload.DraggedAppointments.OfType<object>().Contains(i));
					(listBox.ItemsSource as IList).AddRange(payload.DraggedAppointments);
				}
			}
		}
 
		private ContentControl CreateDragCue(IEnumerable<IOccurrence> appointments)
		{
			bool isHorizontal = this.EffectiveOrientation == Orientation.Horizontal;
			double ticksPerPixel = this.EffectivePixelLength.Ticks;
 
			StackPanel panel = new StackPanel();
			panel.Orientation = this.EffectiveOrientation;
			panel.Background = new SolidColorBrush() { Color = Colors.Transparent };
 
			foreach (IOccurrence appointment in appointments)
			{
				double lenght = appointment.Duration().Ticks / ticksPerPixel;
 
				AppointmentCueItem item = new AppointmentCueItem();
				item.HorizontalContentAlignment = HorizontalAlignment.Stretch;
				item.VerticalContentAlignment = VerticalAlignment.Stretch;
				item.Height = isHorizontal ? 110 : lenght;
				item.Width = isHorizontal ? lenght : 110;
				item.Content = appointment;
				item.ContentTemplate = this.AppointmentTemplate;
 
				panel.Children.Add(item);
			}
 
			ContentControl cue = new ContentControl();
			cue.Content = panel;
 
			return cue;
		}
	}
}

And I have the following xaml definitions for the listbox and schedule view:

        <telerik:RadScheduleView Name="radScheduleView1"
                                 EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}"
                                 Grid.Column="1"
                                 AppointmentItemContentTemplate="{StaticResource AppointmentItemContentTemplate}"
                                 GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderContentTemplateSelector}">
            <telerik:RadScheduleView.ViewDefinitions>
                <my:DayViewDefinition />
                <my:WeekViewDefinition />
                <my:MonthViewDefinition />
                <my:TimelineViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>
 
            <scheduleView:RadScheduleView.GroupDescriptionsSource>
                <scheduleView:GroupDescriptionCollection>
                    <scheduleView:ResourceGroupDescription ResourceType="Operatives" />
                </scheduleView:GroupDescriptionCollection>
            </scheduleView:RadScheduleView.GroupDescriptionsSource>
 
        </telerik:RadScheduleView>
 
        <ListBox AllowDrop="True" ItemsSource="{Binding}" Name="listBox1"
                 ItemContainerStyle="{StaticResource ListBoxItemContainerStyle}"
                 ItemTemplate="{StaticResource ListBoxItemTemplate}" SelectionMode="Extended"
                 HorizontalAlignment="Left" Width="270">
            <local:ListBoxDragDropBehavior.Behavior>
                <local:ListBoxDragDropBehavior EffectivePixelLength="{Binding EffectivePixelLength, ElementName=radScheduleView1}"
                                               EffectiveOrientation="{Binding EffectiveOrientation, ElementName=radScheduleView1}"
                                               AppointmentTemplate="{Binding DragVisualCueItemTemplate, ElementName=radScheduleView1}" />
            </local:ListBoxDragDropBehavior.Behavior>
            <ListBox.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF4B4B4B" Offset="1" />
                    <GradientStop Color="#FF6E6E6E" />
                </LinearGradientBrush>
            </ListBox.Background>
        </ListBox>

I could really do with cracking this problem ASAP as I have deadlines to meet very soon, I really really appreciate any help you can give.

Thanks,

Dan
Valeri Hristov
Telerik team
 answered on 25 Oct 2011
2 answers
362 views
Hi, can someone tell me how (or maybe it's not possible) to center the content inside the RadRibbonButton? The text and image I set is always left justified for some reason. For each button I add to the tab (or group) I have a large image and text. I would like to center this if possible. HorizontalContentAlignment doesn't seem to do anything.

Example:
RadRibbonButton button = new RadRibbonButton();
ImageSource imgs = ResourceLoader.GetResourceImage(buttonModel.AssemblyViewFileName, buttonModel.ButtonIconResourceName);
 
button.LargeImage = imgs;
button.Size = Telerik.Windows.Controls.RibbonView.ButtonSize.Large;
button.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
button.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;

Or
<telerikRibbon:RadRibbonGroup Header="Common">
                    <telerikRibbon:RadRibbonButton Text="Home" LargeImage="/Resources/Home32.png" Width="70" Size="Large" HorizontalContentAlignment="Center" />
                </telerikRibbon:RadRibbonGroup>

Tina Stancheva
Telerik team
 answered on 25 Oct 2011
1 answer
160 views
Hello,

Practically identical to a thread opened recently for the Silverlight control...

Rather than have the zoom controller on the Image Editor UI default to a value of "100%," I'd like to have the option to default its value to "Auto." Is this property currently implemented and I just don't see it?

Thank you,
Kyle
Iva Toteva
Telerik team
 answered on 25 Oct 2011
1 answer
88 views
Hi,

I want to get all the appointments within the visible range of the scheduleview. If it is day view, all the appointments in that day and if is weekview all the appointments occur in that week..Please help...

With Regards,
Jeyakumar
Valeri Hristov
Telerik team
 answered on 25 Oct 2011
5 answers
449 views
I specified the SelectionBoxTemplate on my ComboBox, but its being ignored. My code is:
<ti:RadComboBox Name="CodeComboBox" Margin="5,0,0,0" MinWidth="80"
            tc:StyleManager.Theme="Office_Blue"
            IsEditable="True"
            ItemsSource="{Binding DataView}"
            DisplayMemberPath="{Binding DisplayColumnName}"
            SelectedValuePath="{Binding KeyColumnName}"
            SelectedItem="{Binding SelectedView}">
         <ti:RadComboBox.SelectionBoxTemplate>
              <DataTemplate>
                  <TextBox Text="Hows it going" Background="Green"/>
              </DataTemplate>
          </ti:RadComboBox.SelectionBoxTemplate>
</ti:RadComboBox>

Am I doing something wrong?
George
Telerik team
 answered on 25 Oct 2011
1 answer
154 views
Hi Telerik,

I am very new to wpf telerik controls. I am using richtextbox. I learn how to add customize text from code behind. But how can I add customize text from ViewModel.

Regards

Animesh
Iva Toteva
Telerik team
 answered on 25 Oct 2011
7 answers
610 views
Hi,

Is it possible to have a RadPane automatically fit to the size of the control its in? I'm guessing this would need to be done at the RadSplitContainer level. Any suggestions?

Thanks!
George
Telerik team
 answered on 25 Oct 2011
2 answers
152 views
Hi there,

I'm having difficulty figuring out how to bind my data ( ObservableCollection(of) ) and to display it as a hierarchy using vb.

I have the following example data, similar to your C# example I saw in another post called Treelistview-Self-Hierarchy.

ID             Name               ParentID
1               John                 NULL                   ** Top level node **
2               Chris                1                      ** Parent is John **
3               Simon                NULL                   ** Top level node **
4               Dave                 1                      ** parent is John **
5               Joe                  3                      ** parent is simon **

** Please note again that the above is an ObservableCollection(Of ) list.

I have the following XAML List view.

<telerik:RadTreeListView x:Name="ParksTreeListView" AutoGenerateColumns="False" IsFilteringAllowed="True" IsBusy="False">
    <telerik:RadTreeListView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}"
                            Header="ID" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"
                            Header="Name" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ParentID}"
                            Header="Parent" />
    </telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>

I then set the ItemsSource in VB:

'Get parks information from SQL database
Dim parksList As ObservableCollection(Of ParksTree) = ParksDB.GetAllParks()
  
'Set Tree items source
ParksTreeListView.ItemsSource = parksList

This displays all the information correctly in grid. However I need to group the items according to it's hierarchy.How can I achieve this with the minimal of fuss?
** Please note I am a newbie! **

Out of interest, the hierachy in my SQL 2008 database uses the new hierarchyid data type. Can the TreeListView use the hierarchyid data directly to generate the tree nodes?
Robert
Top achievements
Rank 1
 answered on 24 Oct 2011
2 answers
479 views
Hello, I'm having trouble figuring out how to add a button dynamically in a radgridview.

I'm porting over working code that used the stock WPF DataGrid control.  This is the method I *used* to use:

  private DataGridTemplateColumn GetButtonColumn(IListPropertyInfo i)
       {
           var buttonTemplate = new FrameworkElementFactory(typeof(Button));          
           buttonTemplate.SetBinding(Button.ContentProperty, new Binding(i.columnName));
           buttonTemplate.SetValue(Button.StyleProperty, DefaultStyles.GridColumnButtonStyle); 

           buttonTemplate.AddHandler(
              Button.ClickEvent,
              new RoutedEventHandler((o, e) => HandleColumnButtonClick(o, e))
          );

           DataGridTemplateColumn c = new DataGridTemplateColumn();
           c.SortMemberPath = i.columnName;
           c.CellTemplate=new DataTemplate() { VisualTree = buttonTemplate };
           AddHeader(c,i);
           return c;
       }

Trying to replicate this using the RadGridView is giving me all sorts of problems, I think I'm going about it entirely wrong so I won't even post my failed attempts as I'm getting all sorts of bizarre errors.

How do I accomplish adding a button column dynamically in code to a RadGridView and setting it to my own event handler (there is an example on here but it's done in xaml and doesn't add an event handler for the button)?

Any help greatly appreciated.
JC
Top achievements
Rank 1
 answered on 24 Oct 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?