|
Hi all,
I have a combo box in my WPF application that displays a confirmation dialog (MessageBox.Show() ) when certain items are clicked.
Ie. I have the following options
- Pending (default selection)
- Completed
- For Review
When the "For Review" option is selected, I display the confirmation dialog.
My problem is that the combo box isn't updated prior to the dialog being displayed. So, even though "For Review" was selected and the Selection_Changed event is firing, the combo box shows "Pending" while the dialog is being displayed.
I've tried some DoEvents loops and even tried changing the combo box selection programatically prior to showing the dialog, all to no avail.
Any ideas?
|
|
|
|
|
Maybe somebody can help me out here...
I have a really really simple Silverlight app calling a web service on a different domain. The silverlight is just a simple login screen, it takes a username and a password and returns true/false.
The values are passed off to my web service and I return the boolean. I have checked out the following:
1) The web service itself works fine. I fired up a different platform and I can hit the web service and get back what I'm expecting from all over the place.
2) The ClientAccessPolicy.xml file is also wide open. I went so far as to play around with it a bit and I know I'm hitting the right one and it's working ok. (I did this by changing the URI to something else and I got shut out as expected, etc.
On my DevBox, it works fine. I can fire up the web site on my machine, and call the web service as expected. Shucks, I can even call up the web site itself on the web server and it works as expected.
It's only when I try to hit the Silverlight web site from other places where I run into problems.
Any chances somebody out there run across this and might know what I'm doing wrong?
Thanks,
Nick
Here's some of the error messages I'm seeing:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Mon, 19 Jul 2010 03:31:43 UTC
Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at xyx.ServiceProxy.GetAllAdvisorStatesCompletedEventArgs.get_Result()
at xyx.App.oProxy_GetAllAdvisorStatesCompleted(Object sender, GetAllAdvisorStatesCompletedEventArgs e)
at xyx.ServiceProxy.svcXYXSoapClient.OnGetAllAdvisorStatesCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://portal.myportal.com/xyx/
Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at xyx.ServiceProxy.LoginCompletedEventArgs.get_Result()
at xyx.MainPage.oProxy_LoginCompleted(Object sender, LoginCompletedEventArgs e)
at xyx.ServiceProxy.svcXYXSoapClient.OnLoginCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://portal.myportal.com/xyx/
This are my own opinions. You know the rest.....
|
|
|
|
|
Make sure you have the client acess policy files in place.
For more information, see here[^].
|
|
|
|
|
Abhinav S wrote: Make sure you have the client acess policy files in place.
That's the one thing I believe I do have in the right place. I kept tinkering with the different settings in it and I was successful at denying myself access to the web service. It's a wide open clientaccesspolicy.xml file right at the moment.
This are my own opinions. You know the rest.....
|
|
|
|
|
At home (http), I think I had to put the clientaccesspolicy.xml file in the root folder of my server (inetpub). At work (https), I put it in the web service's folder.
I can check where I put it when I get home from work.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Well, the solution was the reference to the web service itself. The reference was the internal web service (a.k.a. inside of our firewall) and it was being used by people on the outside of the firewall.
Once we created a proxy service and pointed it it, everything worked fine.
I guess next time, when I inherit code, I probably should deep dive a bit more to figure out how the original designers were makingthings work..
THanks everybody for the help.
Nick
This are my own opinions. You know the rest.....
|
|
|
|
|
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')
|
|
|
|
|
There are many different ways to achieve this. A simple way would be to introduce a view that contains the other views with a VM behind it that contained an ClockType property which is used to determine the visibility of each view. Basically, you'd bind the Visibility of the none-default clock to this property using a DataTrigger to trigger the visibility change.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks - but that's not what I"m getting at, really.
I thought the idea of MVVM is to separate the presentation from the rest of the application.
So I define the requirements of a view (it needs to show the time and allow the Hours Minutes and Seconds to be updated, for example) but leave the presentation up to the designer.
Now the designer wants to show an analogue clock sometimes, and a digital clock other times - no business logic reason, juse pure presentation (you know how these arty types get after a latte!)
Now I can have them develop two separate User Controls (views) both of which use the same VM, and use them where appropriate, or I could create two Vms and have them create a view for each.
But...
At the moment, following much investigation, I am allowing WPF to decide upon the View to use based upon the VM - so neither the view nor the viewmodel are aware of one another's existence, and importantly the designer can see data. In window XAML I had
<Label Name="labelc" ContentTemplate="{StaticResource digitalTemplate}" />
for example.
this gets the template from my resource dictionary, for the digital clock, and all works fine.
but I changed that to use
<Label Name="labelc" ContentTemplateSelector="{StaticResource ClockTemplateSelector}" />
Which, as I said in my original post I think, works fine, but the TemplateSelector seems to work on the principal that it is the ModelView that is going to decide upon which template to use, and not the 'context' in which the view is being viewed.
So what I was hoping for was a way for the templateSelector to be able to determine something about how it is being displayed, and make a decision mased upon that information as to which template to return.
I guess I was just concerened in case I was missing something obvious.
what I'd like to see is :
designer designs templates for Digital and analogue clocks
templateselector is written to use one or the other depending upon the screen real-estate available.
The designer just references the contenttemplateSelector appropriately, and can see, at design time, what the outcome will be.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
_Maxxx_ wrote: neither the view nor the viewmodel are aware of one another's existence
If you have some interaction, the View has to have knowledge of the ViewModel otherwise there is no point in the ViewModel. If you note, I carefully said that there was a containing view which was used to identify the active view by having the VM behind this simply expose a property which a DataTrigger uses to display the relevant trigger. This makes for small, single responsibility VMs with the one behind the clock being responsible for updating the time in the binding, and the one behind the container being responsible for identifying which the active clock should be.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
First, thanks for taking the time to read my waffle, let alone responding
Pete O'Hanlon wrote: the View has to have knowledge of the ViewModel
Yep - badly worded by me. What I mean is that all interaction is done via binding - the only reference in code is in the main window which sets the Content of the labels to an instance of the ClockViewModel- so the VM knows nothing at all about the view, while the view only knows of the ViewModel because its content is an instance of one, and it uses a ContentTemplateSelector to determine how to display it.
The View itself shows the time by binding to the Hours Minutes and Seconds properties of the VM - so sure, it knows there will be a Vm with these properties, but it has no reference to an instance (* of course it does, really, it's just handled by WPF and not me!)
I agree your solution works, and works fine - what I am looking at, though, is the concept more that the practicality of this particular example.
What if I want to introduce a third view? I really wanted the designer to be able to just knock up any number of views to handle the same VM without having to change the VM.
I can extend your idea to use an enumerating rather than a boolean - but again that requires that I know all of the views in advance.
So here's what I would like to happen:
I write my ClockVM with appropriate properties.
I write a TemplateSelector which, based upon something in the View, determines which template (IOW which View) to select.
The designer designs several views.
The designer adds templates to the dictionary
I add code to the Window which sets the Content of each control to it's VM - without knowledge of whether this is a digital, analogue or something else version.
Ideally then, without any code changes to the Template Selector, it just works!
This requires that the template selector has access to something in the view which tells it which template to return.
So (as a poor example) I'd like the designer to be able to put a control on the window, and set something (in Xaml) to tell the SelectTemplate method which template to select.
I think my lack of understanding of WPF is hampering me somewhat - maybe it's just not possible to do what I want (maybe it's not sensible!)
Essentially what I am working toward is the idea that a number of viewmodels can be created and given to a design team who can put the gui side of the application together with little or no help from the development team.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hey,
Looking for some help on Binding to the selectedDates property of the calendar control.
I have an observable collection of my own appointments objects and this class has a date property. So I want the calendar control to show all the dates from the observable collection. Not sure how to do this. I know how to manually set the dates in the calendar control and they show up with the light blue box around them.
If anyone could point me in the right direction that would be great
Thanks
|
|
|
|
|
|
I'm working with .net 4.0.
So its basically saying that I cant actually bind to the SelectedDates property and have to do the work in the code behind.
|
|
|
|
|
Hi all,
I checked the validation for my form by using DataAnnotations.
<br />
[Required(ErrorMessage="User Name is Required")]<br />
[StringLength(12,MinimumLength=6,ErrorMessage="User Name must be in between 6 to 12 Characters")]<br />
public string UserName<br />
{<br />
get { return _UserName; }<br />
set <br />
{<br />
<br />
Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName="UserName"});<br />
_UserName = value; <br />
}<br />
} <br />
The error is always throwed at [Validator.ValidateProperty] and applicaton is stopped!! why on my friend's PC is not and the error message is displayed near the textbox normally.
The strange is any source code that i got from internet or from my friend's PC is run normally with DataAnotation. But when i clean project and build it again, the application always throw error ( like : value is required ... ) at Validator.ValidateProperty and application is exited ( or stop running )
How could i solve it ?
|
|
|
|
|
Hi,
I want to develop a web site in silverlight completely,It's a website for getting advertisments.
Will I encouner any problem?
I mean it is OK if develop a web site fully in silverlight
Best wishes
|
|
|
|
|
mehrdadc48 wrote: Will I encouner any problem?
What types of problem you are expecting there?
mehrdadc48 wrote: I mean it is OK if develop a web site fully in silverlight
Why not? There are several websites now fully developed in Silverlight.
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
See this interesting discussion here[^].
Might give you some confidence to start developing in Silverlight.
|
|
|
|
|
OK, I'm playing with WPF MVVM
I'm using a resource dictionary to define which view to be used for which viewmodel.
e.g.
<DataTemplate DataType="{x:Type vm:ClockViewModel}">
<vw:DigitalClock/>
</DataTemplate>
then in my Window code behind I have
ClockViewModel vm1 = new ClockViewModel();
tabItem1.Content = vm1;
Sofa so good - but in this particular case I have a clock model - and I can choose either a digital or analogue view. The default in the dictionary is the digital clock.
I know I could stop using the dictionary and simply instantiate the view myself and give it a ClockViewModel as a DataSource, but I rather like the elegance of the Dictionary.
I can't figure out if it is possible to keep using the dictionary, but override the process on occasion.
Remember, I'm a WPF newbie, so if I am missing something obvious, be gentle
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I think you can make use of template selector concept. You can create a user control with DataTemplateSelector, check property in your view model and switch between analog and digital clock usercontrols accordingly.
Try Google for some tutorials,
DataTemplateSelector WPF[^]
|
|
|
|
|
Thanks - I'm Binging it now (not really, I'm googling).
Sometimes it's just finding that right keyword...
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Googled, found, implemented and Bobn's your Uncle - thanks!
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
_Maxxx_ wrote: Bobn's your Uncle
Bob's your uncle
I guess you use DataTemplateSelector.right?
|
|
|
|
|
Arun Jacob wrote: Bob's your uncle
Actually, Bob's transgender so now Bob's your aunt.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'd start looking into DependencyInjection if I were you.
Maybe even Prism ...
|
|
|
|