this is the exact code i use. The Problem is not in storing and retrieving of the cookie, but it lies in transporting it from the Silverlight to a service.when i pass it to a service method, on the way the value get lost. This code was working for days, after i formated my machine the same thing does not work anymore.
This is my generic functions i use to deal with cookies and when i debug i can see the value be retrieved from a cookie and being passed to a wcf method.
I also just started programming with MVVM pattern and I had a good start looking at Karl Shifflet's MVVM training "In the Box".
Try it out, it should provide you with a brief overview to start with: In the Box MVVM Training[^]
The two main advantages I see in using the ViewModel is that it allows you to write unit tests and separates the various concerns making for a cleaner implementation.
You can't unit test the code behind your view but you can unit test the ViewModel code. So by seperating your presentation logic from the view itself, you create a more reliable solution. Not sure if you are actually reducing the amount of code. It's just moved to the ViewModel
You can bind directly to the model but writing presentation logic (adding properties, sort routines etc) in the model creates performance issues and confuses other developers about the purpose of the model. So by using the ViewModel class to implement this logic, you can avoid these problems.
The idea behind MVVM is simple, finding good articles which step you through implementing MVVM can be hard to hard to find but MVVM fits nicely with the WPF/Silverlight data binding model.
I read about MVVM model. Using MVVM model i can reduce the code behind.
What does it Mean?
The idea of the code-behind reduction is that you remove any code-behind that is not strictly to do with the presentation of the data - thus you separate the presentation completely, allowing the presentation to be changed independently of the rest of the application.
Member 4550493 wrote:
As MVVM model is separating the view, Model and ViewModel.
What is the actual use of ViewModel.
I think of the viewmodel as being what the name suggests - a model of the view. if you're going to have a form that dispays a list, and allows the user to select an item from the list to "do something" with, then the view model will contain a property holding the list's elements, and functionality to "do something" with an element of that list.
You can write tests against the ViewModel without worrying about visual controls, and the ViewModel becomes ,as it were, the specification of the View.
Member 4550493 wrote:
can't I bind the data from model itself rather than ViewModel?
Sure you can - but the idea of the viewmodel its to separate your presentation from dependency on your data - and vice versa. In order to present data to the user, you may need to manipulate that data in some way - and if you do this in the model in order to be able to bind to it, then you're tying your Data to the View. Fine in principal, until something changes
As an example. Say you have a Time stored in the DB and you ant to display it - you retrieve it into a model that contains a DateTime value.
You want to display the time as an analogue clock. So you need angles for the hands.
Easy, you say, add properties of HoursAngle, and MinutesAngle to your model and bind to them.
It works - but it's just Not Right, is it? What business has the model got in presenting angles? What if you now decide youwant to display the time as a percentage of the passage of a day? add more properties to the Model?
A better way is for the model to present the time as a datetime, and the ViewModel to provide bindable properties, where necessary, to provide the Gui representations.
(note this isn't necessarily a real world example - there are other ways of presenting an analogue clock than binding to an HoursAngle propery on a Viewmodel or a Model)
I waffled on for four articles about MVVM - which may help, or may not - see my sig for a link
My Project is devoloped with silverlight4.
In my Project i have used some telerik controls with version 3.
But, the problem with my application is it is taking too much memmory.
Actually my Application is showing records for perticular order no,
so, can u help me.
How can i reduce the memory?
I had checked it in Task Manager.
Actually i havent devoloped this Application.
I am just going through it and i came to know that it is making full cpu usage.
can suggest me what are the possibilities of it?
How do i overcome it?
I recently wrote an article about what Telerik did.
They have created something they named "Minifier" it takes your silverlight project and remove unused things and leave you with a optimized project. You should even try their "JustCode" it makes sure you have neat code that has less bugs.
Assuming the default TAB behavior (i.e. tabbing out of the final cell moves the focus from the grid to the next control) I would try providing a LostKeyboardFocus that inserts a row, and brings the focus back into the initial cell of that newly inserted row.
P.S. This may or may not work when there are no other controls on the page: I do not know if you get a LostKeyboardFocus+GotKeyboardFocus when the focus circles back to the same control.
In my wpf application, there are several textboxes to show the values of the data in the database.
The storedprocedure used, returns fields such as Notes and EnglishNotes as you see in xaml below.
The problem is that txtNotes always shows the value in txtEnglishNotes
I have checked and the storedprocedure does return the correct value for Notes and EnglishNotes but somehow the two textboxes show the value in txtEnglishNotes always.
Do you see why please?
Look for any code that refers to those text boxes... Maybe you're doing something with them in the code-behind that you forgot about. If you have trouble finding it, remove their names (WPF controls usually don't need names) and see what breaks.
Set breakpoints in the getters for the bound properties, and check their values when they're actually retrieved... If they're dependency properties, add a PropertyChanged handler to the definition and set a breakpoint to see if they're being changed.
HOw do I put "Set breakpoints in the getters for the bound properties" ?
I ask because at present I am not using field properties as in get or set...
So not sure where you mean to place breakpoint.
When you read the values out of the database, where do you put them? There must be some piece of code that contains these properties. Put the breakpoints on the code that populates these properties - this is debugging 101; you need to learn this stuff rather than coming here and asking us to solve this without sight of your code.
Well, you have bound the controls to the Notes and EnglishNotes properties of some Class. Therefore, you need to set the breakpoint in the setter for these properties. Then when these properties get updated, you can check whether the expected values for these properties are being set. This sounds like a classic case of two properties getting set to the same value like this