public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ICollection<
DocumentResultHit
> results = ResultHitManager.GetDummyData();
//Add the known columns
this.radGridView1 .Columns.Add(new GridViewDataColumn()
{
UniqueName = "DocId"
,
DataMemberBinding = new Binding("DocumentID")
});
//add the dynamic columns
List<
string
> docColumns = ResultHitManager.GetDocumentColumns();
foreach(string str in docColumns )
{
GridViewDataColumn docCol = new GridViewDataColumn();
docCol.Header = str;
docCol.DataMemberBinding = new Binding(("SearchFields["+str+"]"));
this.radGridView1.Columns.Add(docCol);
}
// Finally, bind the grid
this.radGridView1 .ItemsSource = results ;
}
}
public class DocumentResultHit
{
public int DocumentID
{
get;
set;
}
Dictionary<
string
, List<string>> searchFields = new Dictionary<
string
, List<string>>();
public Dictionary<
string
, List<string>> SearchFields
{
get { return this.searchFields ; }
}
public IList<
PageResultHit
> Pages { get; set; }
}
public static class ResultHitManager
{
public static ICollection<
DocumentResultHit
> GetDummyData()
{
ICollection<
DocumentResultHit
> results = new List<
DocumentResultHit
>();
DocumentResultHit doc1 = new DocumentResultHit() { DocumentID = 1 };
doc1.SearchFields.Add("DocCol1", new List<
string
>() {"MultiField1", "MultiFiled2"});
doc1.SearchFields.Add("DocCol2", new List<
string
>() { "MultiField3", "MultiFiled4" });
PageResultHit page1 = new PageResultHit();
page1.PageFields.Add("PageCol1", new List<
string
>() { "MultiPageField1", "MultiPageFiled2" });
page1.PageFields.Add("PageCol2", new List<
string
>() { "MultiPageField3", "MultiPageFiled4" });
doc1.Pages = new List<
PageResultHit
>();
doc1.Pages.Add(page1);
results.Add(doc1);
DocumentResultHit doc2 = new DocumentResultHit() { DocumentID = 2 };
doc2.SearchFields.Add("DocCol1", new List<
string
>() { "Multidoc2Field1", "Multidoc2Filed2" });
doc2.SearchFields.Add("DocCol2", new List<
string
>() { "Multidoc2Field3", "Multidoc2Filed4" });
results.Add(doc2);
return results;
}
public static List<
string
> GetDocumentColumns()
{
return new List<
string
>() {"DocCol1", "DocCol2"};
}
public static List<
string
> GetPageColumns()
{
return new List<
string
>() { "PageCol1", "PageCol2" };
}
}
public
{
InitializeComponent();
ICollection<DocumentResultHit> results = ResultHitManager
this.radGridView1 .Columns.Add(new GridViewDataColumn
{
UniqueName =
,
DataMemberBinding =
new Binding("DocumentID"
});
List<string> docColumns = ResultHitManager
foreach(string str in
{
GridViewDataColumn docCol = new GridViewDataColumn
docCol.Header = str;
docCol.DataMemberBinding =
new Binding(("SearchFields["+str+"]"
this
}
this
}
}
public class
{
public int
{
get
set
}
Dictionary<string, List<string>> searchFields = new Dictionary<string, List<string
public Dictionary<string, List<string
{
get { return this
}
public IList<PageResultHit> Pages { get; set
}
Finally here is the "GetDummyData" and "GetDocumentColumns" method
public static ICollection<DocumentResultHit
{
ICollection<DocumentResultHit> results = new List<DocumentResultHit
DocumentResultHit doc1 = new DocumentResultHit
doc1.SearchFields.Add(
"DocCol1", new List<string>() {"MultiField1", "MultiFiled2"
doc1.SearchFields.Add(
"DocCol2", new List<string>() { "MultiField3", "MultiFiled4"
PageResultHit page1 = new PageResultHit
page1.PageFields.Add(
"PageCol1", new List<string>() { "MultiPageField1", "MultiPageFiled2"
page1.PageFields.Add(
"PageCol2", new List<string>() { "MultiPageField3", "MultiPageFiled4"
doc1.Pages =
new List<PageResultHit
doc1.Pages.Add(page1);
results.Add(doc1);
DocumentResultHit doc2 = new DocumentResultHit
doc2.SearchFields.Add(
"DocCol1", new List<string>() { "Multidoc2Field1", "Multidoc2Filed2"
doc2.SearchFields.Add(
"DocCol2", new List<string>() { "Multidoc2Field3", "Multidoc2Filed4"
results.Add(doc2);
return
}
public static List<string
{
return new List<string>() {"DocCol1", "DocCol2"
}
Hi,All:
My application use Win32 window to host my WPF window. I am using WindowInteropHelper to set my WPF window owner to the Win32 window handler. It works fine. But If I move the Win32 window (like to 2nd screen), the WPF window does not move with it. I have to manually set the WPF window Left, top, Width and Height. Is this by design or did I miss something here? What is the difference between the Owner and Parent (window)? Should I set the WPF parent window to the win32 handler to let the WPF window move with the win32 window?
Code snippet:
IntPtr win32WndHandler;
WindowInteropHelper helper = new WindowInteropHelper(myWPFWindow);
helper.Owner = win32WndHandler;
Thanks a lot
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; } }}