or
I have some backend code that needs to look at a collection of appointments and determine which ones are active now.
Are there any helper methods that would assist in determining this? or Will I have to use the appointment.Start & appointment.End times in conjunction with the appointment.RecurrenceRule.Patten & appointment.RecurrenceRule.Exceptions to determine which ones are active.
Thanks
Craig.
<Window x:Class="DoubleClickEventFiredTwice.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4" Title="MainWindow" Height="350" Width="525" x:Name="window"> <Grid> <telerik:RadGridView Margin="12" ShowGroupPanel="False" ItemsSource="{Binding Employees}" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="False" IsReadOnly="True" SelectedItem="{Binding Path=SelectedEmployee, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CanUserInsertRows="False" CanUserDeleteRows="False" DataLoadMode="Asynchronous" PreviewMouseDoubleClick="RadGridView_PreviewMouseDoubleClick"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name, Mode=TwoWay}" Width="1*" /> </telerik:RadGridView.Columns> <telerik:RadGridView.ChildTableDefinitions> <telerik:GridViewTableDefinition> <telerik:GridViewTableDefinition.Relation> <telerik:PropertyRelation ParentPropertyName="Notes" /> </telerik:GridViewTableDefinition.Relation> </telerik:GridViewTableDefinition> </telerik:RadGridView.ChildTableDefinitions> <telerik:RadGridView.HierarchyChildTemplate> <DataTemplate> <telerik:RadGridView x:Name="GridViewDetail" CanUserFreezeColumns="False" AutoGenerateColumns="False" ItemsSource="{Binding Notes}" ShowGroupPanel="False" IsReadOnly="True" CanUserInsertRows="False" SelectedItem="{Binding Mode=TwoWay, Path=DataContext.SelectedNote, RelativeSource={RelativeSource FindAncestor, AncestorType=Window, AncestorLevel=1}}" CanUserDeleteRows="False" DataLoadMode="Asynchronous" PreviewMouseDoubleClick="RadGridView_PreviewMouseDoubleClick"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Text, Mode=TwoWay}" Header="Note" Width="200" /> </telerik:RadGridView.Columns> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDoubleClick"> <cmd:EventToCommand Command="{Binding Mode=OneWay, Path=DataContext.EditNoteCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=Window, AncestorLevel=1}}" PassEventArgsToCommand="True" /> </i:EventTrigger> </i:Interaction.Triggers> </telerik:RadGridView> </DataTemplate> </telerik:RadGridView.HierarchyChildTemplate> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDoubleClick"> <cmd:EventToCommand Command="{Binding EditEmployeeCommand, Mode=OneWay}" PassEventArgsToCommand="True" /> </i:EventTrigger> </i:Interaction.Triggers> </telerik:RadGridView> </Grid> </Window>
using System; using System.Linq; using System.Windows; using System.Windows.Input; using Telerik.Windows.Controls; using Telerik.Windows.Controls.GridView; namespace DoubleClickEventFiredTwice { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); this.DataContext = new ViewModel(); } private void RadGridView_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { var clicked = e.OriginalSource as UIElement; e.Handled = clicked == null || clicked.ParentOfType<GridViewRow>() == null; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Input; using GalaSoft.MvvmLight.Command; namespace DoubleClickEventFiredTwice { public class ViewModel { public ViewModel() { this.EditEmployeeCommand = new RelayCommand<RoutedEventArgs>( args => this.EditEmployee(this.SelectedEmployee), args => this.SelectedEmployee != null); this.EditNoteCommand = new RelayCommand<RoutedEventArgs>( args => this.EditNote(this.SelectedNote), args => this.SelectedNote != null); } public IList<Employee> Employees { get { return new List<Employee> { new Employee { Name = "Hans Meier", Notes = new[]{ new Note { Text = "Hinweis 1"}, new Note { Text = "Hinweis 2"} }}, new Employee { Name = "Klaus Schuster", Notes = new[]{ new Note { Text = "Hinweis 3"}, new Note { Text = "Hinweis 4"} }} }; } } public Employee SelectedEmployee { get; set; } public Note SelectedNote { get; set; } public ICommand EditEmployeeCommand { get; private set; } public ICommand EditNoteCommand { get; private set; } public void EditEmployee(Employee item) { MessageBox.Show(item.Name); } public void EditNote(Note item) { MessageBox.Show(item.Text); } }public class Employee { public String Name { get; set; } public IList<Note> Notes { get; set; } }public class Note { public String Text { get; set; } }}