Telerik Forums
UI for WPF Forum
0 answers
375 views
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" };
        }
    }
Hi,
I want to display a read-only list of valueswhich come from a dictionary type in a gridview column . I cannot do it in XAML as the columns are created at runtime. What is the appropriate column type or should I do it via data templates. Currently with the code below the column displays the text "Collection" .Please help. Here is the code:

 

 

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 ;

 

 

}

 

 

 

}

 



Here is the entity (object called DocumentResulHit ). As shown below "SearchFields" is of type Dictionary and I want to display the value corresponding to the column name key in the cell.

 

 

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

; }

 

 

}

Finally here is the "GetDummyData" and "GetDocumentColumns" method

 

 

 

 

 

 

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"

};

 

 

 

}

 

 

Subarna Bandyopadhya
Top achievements
Rank 1
 asked on 03 Mar 2011
1 answer
266 views

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

Rossen Hristov
Telerik team
 answered on 03 Mar 2011
1 answer
106 views

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.

Valeri Hristov
Telerik team
 answered on 03 Mar 2011
2 answers
241 views
Hello there,

I had a quick look at the Silverlight documentation (is the WPF RichTextBox (beta) Documentation available already somewhere?) and I did not see any Events being mentioned regarding key events, as in e.g. whenever the user enters a key in the editor indicate what key(s) was/were pressed (or e.g. what combo like alt+shift+f etc). Is anything like that available/possible or planned for the editor?

Best regards,
-Jörg B.
Jörg B.
Top achievements
Rank 1
 answered on 03 Mar 2011
1 answer
123 views
Hy,
I know It's not easy but do you predict to manage right to left language like arabic [maybe a gift for the end of the year  ]? A new nice feature to complete this amazing control.
By Example http://msdn.microsoft.com/fr-fr/library/aa350685.aspx
Amts
Mr Bernard JOURDAIN 
Agency Press France
Iva Toteva
Telerik team
 answered on 03 Mar 2011
1 answer
72 views
Is there a way to rotate the data?

I've got a collection of objects, but I want the properties to show up as rows and the data points to show up as columns.
Rossen Hristov
Telerik team
 answered on 03 Mar 2011
2 answers
273 views
Hello,

when I am double clicking on a child row then also then also the event from parent grid will be fired, if a row is selected. How can I supress the event of the parent grid without deselecting the row?

In my example, I am using MVVM Light.

<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 { getset; }
 
        public Note SelectedNote { getset; }
 
        public ICommand EditEmployeeCommand { getprivate set; }
 
        public ICommand EditNoteCommand { getprivate 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 { getset; }
 
        public IList<Note> Notes { getset; }
    }
    public class Note
    {
        public String Text { getset; }
    }
}

Thanks and greetings,
Ronny
Ronny
Top achievements
Rank 1
 answered on 03 Mar 2011
0 answers
98 views
In my application I want to  have an empty datagrid at start. Then the user must be able to add record
the columns in the gridview must  appear as combobox for the user to select the data for entry.
How can this be achieved?
Xaria D
Top achievements
Rank 1
 asked on 03 Mar 2011
1 answer
137 views
Any way to hide the scroll bars on the RadChart?  i seen the thread on here where someone was trying to accomplish the same task, but the code doesn't work for me.  UISpy finds the sliders, but cant seem to locate them dynamically...   any help would be much appriciated. 

On a similar note, when i zoom with multiple line series, the Y axis seems to zoom, but the X axis stays the same...  any ideas?

Thanks,
Brian
Evgenia
Telerik team
 answered on 03 Mar 2011
5 answers
213 views
I am using Telerik controls with version 2010.3.1314.35.

In my WPF application , i need to have a treeview which accepts files/folders drag and dropped from desktop or any other windows folders.

Also while dragging over the treeview nodes i need to expand the nodes after a particular time delay.

Above two features are available with Telerik treeview?

If not please suggest any possible workaround solution.

Regards,
Vinodh
Vinodh
Top achievements
Rank 1
 answered on 03 Mar 2011
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?