telerik radscheduler view in wpf - wpf

I am using a telerik RadScheduleView control to display employee records
I have also added custom column names Employee name,start date,end date.
Please help me on how to fetch data from the database and display it on the RadScheduleView control.
I am new to Telerik control.

In order to display Employees in the RadScheduleView you need to bind the AppointmentSource to a model representation (Employee) of the data from your database. Your model representation must implement IAppointment:
I suppose you only require the End (Employee.EndDate), Start (Employee.StartDate) and Subject (Employee.Name) members for now.
That is as far as I can help you start off. More information on Telerik RadScheduleView database binding can be found in the following articles:
Overview
RadScheduleView Types and Sources
Table Definitions and Relationships
List item
Models
View and ViewModel
They even have a sample project for you: http://www.telerik.com/support/code-library/binding-to-database-example

Related

Pass data from datagrid to reportviewer dataset

I have an app in C# WPF with an existing .rdlc file added to a ReportViewer. The report already has datasets. Here is a printscreen: link. Now, I have a DataGrid that's bound to an ObservableCollection. How can I pass data from the collection to the fields of the dataset? The parts of the items of the ObservableCollection have the same type as the fields of the datasets but have different names. So I want the user to be able to select a single row from the DataGrid and the records of this row (parts of an item of the ObservableCollection) to fill the appropriate fields of the dataset thus showing a populated report in my ReportViewer. And whenever the user selects a different row, the data in the report should change accordingly. I hope I've been clear. I've read about IEnumerable and List<T> set as datasource but I don't get that. I just want to overwrite the fields of my dataset as if they were parts of a structure or a class and then present them in the formatted report. Can this be done in a similar, simple way? Because I don't know why I would want to take my item from the ObservableCollection and make a List<> out of it. But in case I chose this option should the items of the List<> have the same name and type as the fields in the dataset?
Thank you for your answer in advance!

Common model among multiple views

New to WPF. I have a Product model that is an L2S entity. I am creating an application in WPF to edit the product information to potentially replace an old Windows forms app I have. the application has a tab control with a number of tabs on it, such as Packaging, Marketing, Photos, Construction, etc.
My question is how do I structure this in a MVVM system. Do I have a separate view for each tab, each with it's own view model relating to it's particular subset of the Product model? Or do I have a single view with the tab control and all of the fields and a single view model to encompass the model in it's entirety? Or am I going about it completely wrong?
I feel like the first option is the way to go, but then I am also unsure of how to share the same model across multiple view models. Can anyone shed some light on this for me?
--Edit--
Examples of data on the pages:
Marketing has several text fields, and a few subset entity collections such as features, applications, and cross references.
Photos handles a collection of Photos for the product
Packaging and Construction are each a large collection of text fields/combos/checkboxes related to their respective information in the Product
With this minimum of info you've provided I would suggest following solution:
Main ProductView view
Separate View for the each tab
Main container ViewModel: ProductViewModel
For complex tabs separate view model as well. For instance you would have a separate PackagingViewModel so ProductViewModel should expose public PackagingViewModel Packaging property
ProductViewModel should accept all model-related stuff (perhaps some services, model entity, etc) and then initialize all other child view models.

How to assign context and refresh it in Entity Framework?

I created a new entity object and bound it to controls in another window (edit window). After modifying and saving I assigned a new entity object into the one in the main window. The old entity object is bound into a datagrid, now I want the datagrid to display the data that I had modified and saved.
ObjectContext.Refresh Method (RefreshMode, Object) seems to be what I want but I don't know how to use it correctly.
In short :
I have a main window with datagrid displaying the whole data of the table. Users can pick one row and edit it in a edit window. After saving, the datagrid should display what has been modified.
Your best bet here is to use an ObservableCollection as your data source for the datagrid instead of the query.
And look at implementing INotifyPropertyChanged interface in your Customer class.
The ObservableCollection is initially populated by the database query. User changes are made to elements within the ObservableCollection and once complete you then just need to trigger transferring the changes to wherever you originally obtained your list of Customer objects
By doing this changes made both to the collection of Customers and to individual Customer objects (if present within the datagrid) will be automatically updated for you.
edit
I must admit that I'm a bit rushed to offer up any code at the moment, but here's a pretty good article that explains how to use ObservableCollections and classes that implement INotifyPropertyChanged. It also has code examples, which although in VB.NET should give you enough of an idea to get started.
In effect you separate your code into distinct layers UI (View), business logic (View Model) and data layer (Model where your entity framework resides).
You bnd your datagrid to the ObservableCollection type property in your Customers class and your edit csutomer window is bound to as instance of your Customer class.

Create WPF GridView Columns Automatically

I need to create a table structure that will automatically create columns for a collection of objects (the structure of which is pretty flexible). The data in the table will only be read only so I've been looking into using a GridView but can't figure out how to automatically generate the columns - has anyone got an example or a URL explaining how to do it?
I'm not totally adverse to using the DataGrid control included as part of the WPF ToolKit, but it seems a little over-kill for displaying readonly data...
I would look at this post on generating the columns for a GridView:
WPF GridView with a dynamic definition
Using the DataGrid would definitely be overkill.

How to set up Header/Lines in WPF/Silverlight

Do you have any best practices for setting up Header/Lines forms (Also known as Header/Details) in WPF or Silverlight? Preferably using the Mode-View-ViewModel design Pattern to fit in with the rest of my application.
An example would be if I had a grid that displayed all SalesOrders in the database, and the underneath that a grid that showed all of the SalesOrderDetails (The individual lines for the sales order...each item sold) for the selected sales order in the top grid.
I realize I could do this in the code behind file on the Grid's SelectionChanged event, but I'd prefer a declarative way of doing so...in all XAML and ViewModel code. Is this possible?
Thanks,
Roy
Header/Lines sounds a lot like the Master - Detail pattern to me. To implement something like this using MVVM is quite simple.
If we were to create a structure where we had a MasterViewModel and a DetailViewModel then in our MasterViewModel we would simply need a property to represent our list of Details and the current Detail. In the View we can bind a list's ItemSource to the collection of Details and bind the SelectedItem to the CurrentDetail property. We can then have a seperate View, as a DataTemplate or UserControl, that represents the CurrentDetail and displays our values in the detail grid.
There's also some good resources out there on implementing a Master Detail pattern XAML.
Bea Stollnitz has two excelent samples using XML for the Data Sources: Here and Here.
There's a MSDN video on implementing the pattern in WPF. (The video is in VB but the code can be downloaded in C#).
In this MSDN forums discussion Johnny Q. demonstrates a simple Master-Detail settup using MVVM.
A lot of Karl Shifflett's examples also end up demonstrating the Master-Detail pattern, though the code is usually in VB (however some examples come with both C# and VB code.)

Resources