Click here to Skip to main content
15,915,805 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: SL Toolkit v4 - Install issues Pin
Rob Graham19-Jul-10 10:23
Rob Graham19-Jul-10 10:23 
QuestionHow to update combo box selection before prompt Pin
D.Dubya19-Jul-10 3:27
D.Dubya19-Jul-10 3:27 
QuestionCan't hit my asmx from Silverlight.. Pin
Nick Jacobs18-Jul-10 17:35
Nick Jacobs18-Jul-10 17:35 
AnswerRe: Can't hit my asmx from Silverlight.. Pin
Abhinav S18-Jul-10 18:11
Abhinav S18-Jul-10 18:11 
GeneralRe: Can't hit my asmx from Silverlight.. Pin
Nick Jacobs19-Jul-10 2:21
Nick Jacobs19-Jul-10 2:21 
GeneralRe: Can't hit my asmx from Silverlight.. Pin
#realJSOP19-Jul-10 3:47
professional#realJSOP19-Jul-10 3:47 
GeneralRe: Can't hit my asmx from Silverlight.. Pin
Nick Jacobs21-Jul-10 17:37
Nick Jacobs21-Jul-10 17:37 
QuestionMore MVVM WPF Angst Pin
_Maxxx_18-Jul-10 16:49
professional_Maxxx_18-Jul-10 16:49 
I am playing with WPF using MVVM.

I am having problems so thought I'd just write it down and see what you chaps think..

I have a Model which (for the sake of my example, but this is more of a generic question) is a clock. It basically just keeps time. It could as easily be a customer or a student or a widget.

I have a ViewModel which (if I understand all this correctly) represents the graphical display of my model but doesn't constrain how it is presented. So, my design team can make a fancy display with bizarre fonts and it doesn't affect the back-end one jot.

Now, I decided that having just one way to view a clock was rather boring. On some pages I want an analogue clock (because there's plenty of room) but on others I just want a simple label, on others I may want something completely bizarre.

So I want to enable multiple views for a single ViewModel.

I can do that using a TemplateSelector(thanks to those who helped below) - the Xaml asks which template to use, at runtime and design time.

But my Clock Model object doesn't change - it doesn't have a property telling the GUI how it should be displayed - that's up to each View to decide. But in the TemplateSelector I just have access to the object (my ClockViewModel) and the DependencyObject which (if I understand things) is the container in which my clockview is to be displayed.

But How does the Designer tell the TemplateSelector which template to display in this instance?

By way of experiment I have

if (((Label) ((ContentPresenter) container).TemplatedParent).Name == "labela")
{
	return DigitalTemplate;
}
else
{
	return AnalogueTemplate;
}


and I give labela and labelb the same VM in the main window.

But this is a little, erm, contrived!

In non-techo land the 'if ' should be saying

"If we want to display the clock as an digital clock"

but how can the designer 'tell it' that that's what they want?

I just used labels in the above because I wanted to see if I could - but obviously it may not be a label that the designer uses.

In the real world, I can see that a designer may display the Customer Surname and initials sometimes, their full name at other times and their Name address and inside leg measurements at others - maybe even in response to the available screen real-estate as it dynamically changes.

I had thought that using the TemplateSelector would be the way to go - but I can't figure out how to do this sort of thing without modifying my ViewModel to include an additional property or properties - but that now means that the designer is driving changes to my viewmodel...

As Professor Backward said "!pleH"

Thanks
___________________________________________
.\\axxx
(That's an 'M')

AnswerRe: More MVVM WPF Angst Pin
Pete O'Hanlon18-Jul-10 21:46
mvePete O'Hanlon18-Jul-10 21:46 
GeneralRe: More MVVM WPF Angst Pin
_Maxxx_19-Jul-10 0:44
professional_Maxxx_19-Jul-10 0:44 
GeneralRe: More MVVM WPF Angst Pin
Pete O'Hanlon19-Jul-10 0:57
mvePete O'Hanlon19-Jul-10 0:57 
GeneralRe: More MVVM WPF Angst Pin
_Maxxx_19-Jul-10 14:36
professional_Maxxx_19-Jul-10 14:36 
QuestionWPF Calendar Binding Pin
carrigart18-Jul-10 6:33
carrigart18-Jul-10 6:33 
AnswerRe: WPF Calendar Binding Pin
Parwej Ahamad18-Jul-10 8:20
professionalParwej Ahamad18-Jul-10 8:20 
GeneralRe: WPF Calendar Binding Pin
carrigart18-Jul-10 9:37
carrigart18-Jul-10 9:37 
QuestionValidator.ValidateProperty always throw error and application is exited Pin
ctlqt1217-Jul-10 23:10
ctlqt1217-Jul-10 23:10 
QuestionFull Silverlight website Pin
mehrdadc4816-Jul-10 18:33
mehrdadc4816-Jul-10 18:33 
AnswerRe: Full Silverlight website Pin
Kunal Chowdhury «IN»17-Jul-10 4:45
professionalKunal Chowdhury «IN»17-Jul-10 4:45 
AnswerRe: Full Silverlight website Pin
Abhinav S17-Jul-10 6:35
Abhinav S17-Jul-10 6:35 
QuestionWPF MVVM Multiple Vs with one VM Pin
_Maxxx_15-Jul-10 19:51
professional_Maxxx_15-Jul-10 19:51 
AnswerRe: WPF MVVM Multiple Vs with one VM Pin
Arun Jacob15-Jul-10 21:47
Arun Jacob15-Jul-10 21:47 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
_Maxxx_16-Jul-10 0:20
professional_Maxxx_16-Jul-10 0:20 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
_Maxxx_16-Jul-10 0:24
professional_Maxxx_16-Jul-10 0:24 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
Arun Jacob16-Jul-10 0:28
Arun Jacob16-Jul-10 0:28 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
Pete O'Hanlon16-Jul-10 1:38
mvePete O'Hanlon16-Jul-10 1:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.