Greetings,
I have a problem with RadScheduleView (WPF). I am starting with it and I have read from you documentation that if I make double click on the schedule view then "create dialog" should appear but i does not. Edit dialog and Delete dialog for existing event will appear but create dialog never shows. I have very easy application. I just put RadScheduleView from toolbox and made binding.
You can see it at the bottom
Could you tell me what I am doing wrong?
Thanks
Dusan Hudecek
MainWindows.xaml:
<Window x:Class="SchedulerWPF2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid>
<telerik:RadScheduleView AppointmentsSource="{Binding Appointments}" HorizontalAlignment="Left" Margin="10,10,0,0" Name="radScheduleView1" VerticalAlignment="Top">
<telerik:RadScheduleView.ViewDefinitions>
<telerik:DayViewDefinition />
<telerik:WeekViewDefinition />
<telerik:MonthViewDefinition />
<telerik:TimelineViewDefinition />
</telerik:RadScheduleView.ViewDefinitions>
</telerik:RadScheduleView>
</Grid>
</Window>
MainWindow.xaml.cs:
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.ScheduleView;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
namespace SchedulerWPF2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public DataContext dc = new DataContext();
public RadObservableCollection<IAppointment> Appointments { get { return dc.Appointments; } set { dc.Appointments = value; } }
public MainWindow()
{
InitializeComponent();
dc.Appointments = new RadObservableCollection<IAppointment>();
this.DataContext = dc;
Appointment a = new Appointment();
a.Start = DateTime.Now;
a.End = DateTime.Now.AddHours(1);
a.Subject = "test";
dc.Appointments.Add(a);
}
}
public class DataContext
{
public RadObservableCollection<IAppointment> Appointments { get; set; }
}
}
protected override void CopyContentFromOverride(DocumentElement fromElement){} protected override void CopyPropertiesFromOverride(DocumentElement fromElement){ base.CopyPropertiesFromOverride(fromElement); //Your properties to copy here this.Name = ((SemanticRangeStart)fromElement).Name; this.Product = ((SematicRangeStart)fromElement).Product;}So I have a dynamic RadGridView using MVVM and Caliburn Micro. This means that I add Columns programmatically to the control. basically like this:
for (int i = 0; i < length; i++)
{
Binding b = new Binding(string.Format("Collection[{0}].ValueIWant", i));
binding.StringFormat = "{0:0.##}";
GridViewDataColumn column = new GridViewDataColumn()
{
Header = HeaderFor(i),
DataMemberBinding = b,
DataType = typeof(double?)
};
Control.columns.Add(column);
}
Now I need to add new lines that show the percentage between line 1 and 2, 2 and 3 and so on.
I've managed to do that but I'm not sure how I would manage to change the String.format specifically for those cells instead of the whole column.
CellTemplateSelector came to mind but I'm not sure that is a good idea as this might mean I have to set the binding again, not knowing the value of i and such. Also I only want to change the string.format on the binding.
As I'm manipulating the number as a double (0,5 is 50%, 50 is 5000%) I guess I have to mask the input as well. not sure if String.Format does that for me as well or if I should use RadMaskedInput
RadContextMenu with Icon, I am using dynamic binding to observable collection, which contains context menu items (Text and Icon), I am following this tutorial "Dynamic Binding", following is my XAML.<Style x:Key="MenuItemStyle" TargetType="{x:Type telerik:RadMenuItem}"> <Setter Property="Icon"> <Setter.Value> <Image Source="{Binding IconPath, Converter={StaticResource pathtoimage}}" /> </Setter.Value> </Setter> </Style> <HierarchicalDataTemplate x:Key="MenuItemTemplate"> <telerik:RadButton Content="{Binding Title}" HorizontalContentAlignment="Left" Background="Transparent" BorderBrush="Transparent" /> </HierarchicalDataTemplate><telerik:RadGridView x:Name="myGridView" AutoGenerateColumns="False" ItemsSource="{Binding GridData}" VerticalAlignment="Top"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Result}" Header="Result"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Category}" Header="Category"/> </telerik:RadGridView.Columns> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu ItemsSource="{Binding ContextMenuItems}" ItemContainerStyle="{StaticResource MenuItemStyle}" ItemTemplate="{StaticResource MenuItemTemplate}"> </telerik:RadContextMenu>class MainViewModel { private ObservableCollection<MenuItemObj> menuitems_; public ObservableCollection<MenuItemObj> ContextMenuItems { get { return menuitems_; } set { menuitems_ = value; } } private ObservableCollection<GridRowDataObj> griddata_; public ObservableCollection<GridRowDataObj> GridData { get { return griddata_; } set { griddata_ = value; } } } public class MenuItemObj { public string Title { get; set; } public string IconPath { get; set; } } public class GridRowDataObj { public string Result { set; get; } public string Category { set; get; } }//TODO ObservableCollection<GridRowDataObj> gd = new ObservableCollection<GridRowDataObj>(); gd.Add(new GridRowDataObj() { Result = "Matric", Category = "SSC" }); gd.Add(new GridRowDataObj() { Result = "FSc", Category = "HSSC" }); gd.Add(new GridRowDataObj() { Result = "FA", Category = "HSSC" }); //TODO ObservableCollection<MenuItemObj> mi = new ObservableCollection<MenuItemObj>(); mi.Add(new MenuItemObj() { Title = "My Item 1", IconPath = "/Images/item1.png" }); mi.Add(new MenuItemObj() { Title = "My Item 2", IconPath = "/Images/item2.png" }); mi.Add(new MenuItemObj() { Title = "My Item 3", IconPath = "/Images/item3.png" }); MainViewModel mvm = new MainViewModel(); mvm.ContextMenuItems = mi; mvm.GridData = gd; this.DataContext = mvm;