In part 7 I create the user interface for the Book Store application. I show how to create a Windows Presentation Foundation (WPF) application that can take advantage of the Visual Studio Data Sources window and DataBinding. Finally I checkin the new project associating it with the developer task.
hi my name is Julio Casal and in this
video I will show you how to create user
interface for our bookstore sample
application using visual studio 2010
remember we are using beta 2 of both
Visual Studio 2010 and team Foundation
server 2010 so as you might remember H
we have this task at hand build the book
list screen and we have already created
the business s of this by creating the
book manager
class that would return a list of books
okay now for this H for this video we
are not only creating a a a window that
will show all the books but we'll also
be able be able to filter the books
using the book type so I I already
created another method get book list
using the book type parameter that will
filter the list using this uh word
syntax in the link query so let's close
this and this and let's
create right click at new project let's
create a WPF application that we will
just
call bookstore.
Windows okay
so right now the the project is been
created and we get this um Sul designer
here we will first work a little bit in
the layout so let's click over here so
we get two rows here in this grid layout
and what we want to do right now is to
add a stack panel in the top so we will
play some controls there let's open all
the blf
controls look for stack panel we will
place this here okay
let's make it take all the available
space
here
okay
nice okay so now that we have that let's
start by adding our our data Grid in
order to do that let's go to data show
data sources let's click add new data
source click
object let's add a reference because we
have not added a reference to the
business project click
okay we can see the list of entities
here let's select book click finish and
what we get in the left side in the data
sources is the layout of the book uh
entity that we created in the past
video okay let's wait a little
bit okay as you know all this is being
added to Source control which is right
now been done by the by this
wizard so being right
here what we can
do okay what we can do is to just drag
this book entity into the bottom side
okay let's drag it here and you can see
we already have our data grid so let's
just make it fit into the available
space in order to do that we will just
go here to the Su let's close
this
okay and let's modify a little bit of
this um properties like hate we don't
need this the alignment we don't need
that go for the
margin don't want
that right now let's remove the width
and the vertical alignment you can see
it fits the the bottom route right now
in the top side of this let's add some
controls okay let's add a
label let's add um text box and a
button okay we'll we will want to have
this stack panel use a different
orientation like an horizontal
orientation you can see for the label
let's
put type or maybe book type for the text
box let's change the name
to type text
box and for the button let's name it
search
Buton and the content will be the name
the what we see displayed here will be
search okay this might be too big that
will be good
okay
search and for the margin let's say uh
maybe five z0 Z should be
good okay now the hate of this uh top uh
grid
row let's go for row
definitions you can see we have two rows
in the top one let's do something like
maybe 40 and in the other one just
asterisk
okay you can see this is the layout we
just got
here
okay so now let's just fix a little bit
also the some properties of these
controls for example the label the
basically the height of this
controls
okay okay
now let's also modify some properties of
the stock panel like the hate the
horizontal
alignment and the vertical
alignment okay might also remove the
width and we have a nice interface right
now okay so in order to retrieve the
actual books to this interface let's
just uh double click in the search
button we get our Handler here and what
we're going to do you can see we we
already have let's just CLI this we
already have some template code here in
order to retrieve the information that
we want let's cut this paste here and
the click you can see that we're
creating um collection view Source
called book VI source that is actually
finding a resource that we already have
in the s that was done by the designer
that resource is right here collection
view Source book view source which is
actually creating creating a design
instance of the book class in this data
grid so we are just finding that
resource here and what we want to do is
to H give some source to the book view
Source okay so this book view source is
the source of the data grid so in order
to do that let's create a book manager
instance you remember we had that object
creting in the other project let's just
add a using statement manager equals new
book
manager and now what we can do is to say
manager that getbook list we will use
our new overload so we will just
say type text
box. text fold the filter and that's it
so now let's test this uh application
okay buug start without debugging oh I
think I missed something maybe we get an
exception
here yes I missed a couple of things
first and most important we need an
application configuration file that we
already have in our
tests this configuration file of course
has the connection string to our to our
uh database which is a SQL Server
Express database so what we're going to
do is just to import that file
into into this project so we will go to
bookstore bookstore. test
let's remove this filter and select ap.
config so we now have it
here right here and second we will just
right click the project and set and say
set as a start a project okay now let's
go debug start without
debugging let's type some filter like
for
example psychology
search and there you go you got all the
psychology books now you can see we
cannot really see too much of these
columns here so make a quick change
here let's go back to the
Sumo and we will find we will find some
interesting uh WID property in all the
columns we will just remove this size to
heater
stuff remove delete delete and delete
and delete let's run this
again and let's
say psychology search and there you go
we have our grid filtering by um by a
book title so that's it let's now just
finish this by doing our checkin right
click the solution check in select our
specific War item which is build the
book list screen click resolve to close
this check
in
okay and that's it
No comments:
Post a Comment