зеркало из https://github.com/telerik/xaml-sdk.git
Examples update
This commit is contained in:
Родитель
cc099fdaa7
Коммит
f1d65557fb
|
@ -1,4 +1,4 @@
|
|||
##Binding to DynamicObject##
|
||||
This example demonstrates how a DynamicObject can be implemented and bound to RadGridView.
|
||||
This example demonstrates how a DynamicObject can be bound to RadGridView.
|
||||
|
||||
<KeyWords: bind, dynamicobject, dynamic>
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
xmlns:my="clr-namespace:ValidateINotifyDataErrorInfo"
|
||||
Title="MainWindow" Height="400" Width="700">
|
||||
Title="MainWindow" Height="600" Width="900">
|
||||
<Window.Resources>
|
||||
<my:MyViewModel x:Key="MyViewModel"/>
|
||||
<Style TargetType="TextBox" x:Key="editorStyle">
|
||||
|
@ -13,7 +13,7 @@
|
|||
<Grid DataContext="{StaticResource MyViewModel}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<telerik:RadGridView Grid.Row="0"
|
||||
|
@ -31,8 +31,14 @@
|
|||
DataFormatString="{}{0:N0}"/>
|
||||
</telerik:RadGridView.Columns>
|
||||
</telerik:RadGridView>
|
||||
<TextBlock Text="RadGridView with dynamic validation" Grid.Row="1"/>
|
||||
<TextBlock Text="RadGridView with dynamic validation. Modifying the data from the first RadGridView, so that a validation error appears, results in an update of the second RadGridView as well."
|
||||
Foreground="DarkRed"
|
||||
HorizontalAlignment="Left"
|
||||
Width="650"
|
||||
TextWrapping="Wrap"
|
||||
Grid.Row="1"/>
|
||||
<telerik:RadGridView Grid.Row="2"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Clubs}"
|
||||
AutoGenerateColumns="False"
|
||||
Margin="5">
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
using System.ComponentModel;
|
||||
|
||||
namespace VariousDataSources
|
||||
{
|
||||
public enum BindingType
|
||||
{
|
||||
[Description("Dynamic Data")]
|
||||
DynamicData,
|
||||
|
||||
[Description("ObservableCollection")]
|
||||
ObservableCollection,
|
||||
|
||||
[Description("Data Table")]
|
||||
DataTable,
|
||||
|
||||
[Description("Xml")]
|
||||
Xml
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace VariousDataSources
|
||||
{
|
||||
public class Club
|
||||
{
|
||||
public Club(string name, DateTime established, int stadiumCapacity)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Established = established;
|
||||
this.StadiumCapacity = stadiumCapacity;
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public DateTime? Established
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int StadiumCapacity
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static IEnumerable<Club> GetClubs()
|
||||
{
|
||||
ObservableCollection<Club> clubs = new ObservableCollection<Club>();
|
||||
clubs.Add(new Club("Liverpool", new DateTime(1892, 1, 1), 45362));
|
||||
clubs.Add(new Club("Manchester Utd.", new DateTime(1878, 1, 1), 76212));
|
||||
clubs.Add(new Club("Chelsea", new DateTime(1905, 1, 1), 42055));
|
||||
clubs.Add(new Club("Arsenal", new DateTime(1886, 1, 1), 60355));
|
||||
return clubs;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
|||
using System;
|
||||
using System.Windows.Data;
|
||||
using Telerik.Windows.Data;
|
||||
using System.ComponentModel;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml;
|
||||
using System.Data;
|
||||
|
@ -182,53 +181,4 @@ namespace VariousDataSources
|
|||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
public class Club
|
||||
{
|
||||
public Club(string name, DateTime established, int stadiumCapacity)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Established = established;
|
||||
this.StadiumCapacity = stadiumCapacity;
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public DateTime? Established
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int StadiumCapacity
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static IEnumerable<Club> GetClubs()
|
||||
{
|
||||
ObservableCollection<Club> clubs = new ObservableCollection<Club>();
|
||||
clubs.Add(new Club("Liverpool", new DateTime(1892, 1, 1), 45362));
|
||||
clubs.Add(new Club("Manchester Utd.", new DateTime(1878, 1, 1), 76212));
|
||||
clubs.Add(new Club("Chelsea", new DateTime(1905, 1, 1), 42055));
|
||||
clubs.Add(new Club("Arsenal", new DateTime(1886, 1, 1), 60355));
|
||||
return clubs;
|
||||
}
|
||||
}
|
||||
|
||||
public enum BindingType
|
||||
{
|
||||
[Description("Dynamic Data")]
|
||||
DynamicData,
|
||||
|
||||
[Description("ObservableCollection")]
|
||||
ObservableCollection,
|
||||
|
||||
[Description("Data Table")]
|
||||
DataTable,
|
||||
|
||||
[Description("Xml")]
|
||||
Xml
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,8 @@
|
|||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BindingType.cs" />
|
||||
<Compile Include="Club.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace CustomDragDropBehavior
|
|||
{
|
||||
public override bool CanDrop(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
|
||||
if (appointment.Resources.Count > 0 && appointment.Resources.First() != state.DestinationSlots.First().Resources.First())
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace CustomDragDropBehavior
|
|||
|
||||
public override void Drop(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
|
||||
if (appointment.IsDraggedFromListBox)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace CustomDragDropBehavior
|
|||
|
||||
public override bool CanStartResize(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
|
||||
if (appointment.IsReadOnly)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ namespace CustomDragDropBehavior
|
|||
|
||||
public override void Resize(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
var destinationSlot = state.DestinationSlots.First() as Slot;
|
||||
var duration = destinationSlot.End - destinationSlot.Start;
|
||||
appointment.Body = "Resize finished. New duration: " + duration.ToString("h\\:mm\\:ss");
|
||||
|
@ -75,14 +75,14 @@ namespace CustomDragDropBehavior
|
|||
|
||||
public override void ResizeCanceled(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
appointment.Body = "Resize Canceled";
|
||||
base.ResizeCanceled(state);
|
||||
}
|
||||
|
||||
public override bool CanStartDrag(DragDropState state)
|
||||
{
|
||||
var draggedAppointment = state.Appointment as CustomAppointment;
|
||||
var draggedAppointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
|
||||
if (draggedAppointment.IsReadOnly)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ namespace CustomDragDropBehavior
|
|||
|
||||
public override IEnumerable<IOccurrence> CoerceDraggedItems(DragDropState state)
|
||||
{
|
||||
var resource = (state.Appointment as Appointment).Resources.First();
|
||||
var resource = (GetAppointment(state.Appointment) as Appointment).Resources.First();
|
||||
var allAppointments = state.SourceAppointmentsSource.Cast<IOccurrence>();
|
||||
var desiredAppointments = allAppointments.Where(a => (a as Appointment).Resources.Any(r => r == resource) && !(a as CustomAppointment).IsReadOnly);
|
||||
return desiredAppointments;
|
||||
|
@ -118,16 +118,28 @@ namespace CustomDragDropBehavior
|
|||
|
||||
public override void DragDropCanceled(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
appointment.Body = "DragDrop canceled at: " + DateTime.Now;
|
||||
base.DragDropCanceled(state);
|
||||
}
|
||||
|
||||
public override void DragDropCompleted(DragDropState state)
|
||||
{
|
||||
var appointment = state.Appointment as CustomAppointment;
|
||||
var appointment = GetAppointment(state.Appointment) as CustomAppointment;
|
||||
appointment.Body = "DragDrop completed at: " + DateTime.Now;
|
||||
base.DragDropCompleted(state);
|
||||
}
|
||||
|
||||
private Appointment GetAppointment(IOccurrence occurance)
|
||||
{
|
||||
var appointment = occurance as CustomAppointment;
|
||||
if (appointment == null)
|
||||
{
|
||||
var currentOccurance = occurance as Occurrence;
|
||||
appointment = currentOccurance.Appointment as CustomAppointment;
|
||||
}
|
||||
|
||||
return appointment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче