Tip:
Highlight text to annotate it
X
transcript by Hamcodi.com
we've data grid for
winforms for a long time
there was no data grid for WPF and in and so it
a lot of feedbacks that it something
obviously for tabular data
a grid is available to to import tabular data
so when you drag and drop
the entity you
get to select what kind of controls you want to generate
so you can say I just generate
a list view which has again
tabular form
but you can modify that if you like to do this or you can generate
single record at a time as details
but the default is the data gird
so generates all of that sets up the master details relationships between the
two
collection view sources and
it generates code behind
to go fetch the data
so essentially what we've done is
the first part of the code that that we see here is
just instantiating this
customer queries and entity objects
looking that from the
resources and then we have a method
called GetCustomerQuery that we declared
and by default because you drag and drop orders and customers custome
customers and orders
what you see here is
NWModel.Customer and we do CustomerQuery.include(orders)
if you want to go and modified that
all you need to do is go and modify this method
or modify the query and then call execute
so what we are binding
to the source
of my collection view resource is
is the result set or etc and in this case we could use link
so it's sets up and I hit f5
display master detail for each of the select for
any of the selected customers it shows me their orders
so if you pointed out that there is now
a WPF data grid
the other thing that I like to
point out is we also have now a calendar control
so a date i can change
so the IDE has also generated
the appropriate template for each cell of data grid
depending to the type that you have selected
so actually that's another good point
so the WPF data grid has
you can bind it
bind it to
an object
it has a property called auto generate columns
and that is set to true
it automatically creates columns for you
with the right types depending on
for each of the
public property of that object
so in our case for
orders for each of orders it could have generated the columns
we se that to false
to allow
in case you want to customize that so if you
if you want everything by default you can just set that to true and and don't need to generate anything else
but if you want specific
types to be generated for each of the columns
such as data templates
that they're there or if you dont want to show all of your columns
I don't want to show my primary key values there it's not very usefull
so all of this is essentially just manuplate go gets
same code that you generate everytime and just create that etc
you can go and modify using
documention modifying queries
and customizes
this approach is also good for people are familiar with winform data binding that's right
so people that are familiar with doing
this for datasets will find it and enjoy
there's walkthrough and example of edm but if i wuold I have added
a data set
it will go the same way same experience for data set and
you can actually go through the data sources wizards add any instance of data sources such as
I got a data set or
web service or objects