|
Have a look at this post[^].
|
|
|
|
|
You can directly bind from XAML like this,
SelectedValue="{Binding UserID}"
|
|
|
|
|
Do the following:
var selectedUser = (from user in usersList
where user.UserId.Equals(selectedUserId)
select user).FirstOrDefault();
drpUserList.SelectedItem = selectedUser;
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
|
|
|
|
|
I have a custom user control loaded in the main window of the application. Inside of the custom user control I have a list box.
If the mouse left click is held down, I want the user to be able to drag the main window to a different location on the screen. Is it possible to handle this event inside of the listbox? If so, how can I go about doing it?
|
|
|
|
|
Try this for a starting point ...
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
|
|
|
|
|
There is a problem with MouseEvents in ListBox - if you click on ListBoxItem, event will be handled and your application will not get event. Possible solutions are useing preview event or using AddHandler for handled events. See this article for sample code: How to Attach to MouseDown Event on ListBox[^]
|
|
|
|
|
hello,
I'm new in Silverlight Development. I want to know how to include "System.Data.SQLClient" in Silverlight application.
In other words, I want to use SQlConnection in Silverlight application
.
Please help
|
|
|
|
|
vinci007 wrote: System.Data.SQLClient
This is not part of the Silverlight runtime.
You can user either Web services or the Entity framework to access data.
|
|
|
|
|
It's simply not possible. Silverlight apps can't connect directly to a database. You have to use a web service (or RIA services).
.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
|
|
|
|
|
you can use the ADO.net DataModel to mappe your Database or the LinqToSQl(dbml)
then you create a WCF for (ADO.Net DataModel) and a web serice for LinqToSql.
|
|
|
|
|
I already had v3 (Nov 2009) installed, and when I added a referenece to my app, everything was fine (the namespaces showed up). So then I installed v4 (Apr 2010), and I didn't see any namespaces for v4 when I tried to change the references.
To try to fix it, I uninstalled both V3 and V4 and then reinstalled v4, but I still don't get the v4 namespaces (or any namespaces for that matter since I uniinstalled v3).
What do I have to do to fix this? Anyone?
.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
|
|
|
|
|
I believe the Silverlight toolkit v4 supports only SL4.
Are you using SL4?
|
|
|
|
|
Yeah, I saw that, but that Delay guy (that's his last name) presented a demo using that version that works on our SL3 systems. I gave up and went back to the prior version (Nov 2009).
I honestly don't understand why they dropped support for SL3 - more often than not, I really hate Microsoft.
.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
|
|
|
|
|
John Simmons / outlaw programmer wrote: presented a demo using that version that works on our SL3 systems
I'd be very interested to know how he did that.
|
|
|
|
|
I ran out of time to be really interested. I had to revert back to v3...
At home, I have SL4 so it's not an issue.
.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
|
|
|
|
|
Ran into something similar - edit your project file and look for a line like:
<Import Condition="$(EnableSilverlightToolkitExtensions)=='true'" Project="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SilverlightToolkit\Tools\v3.0)Microsoft.Silverlight.Toolkit.Build.targets" />
if it's there replace with two lines like:
<Import Condition="$(SilverlightVersion)=='v3.0'" Project="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SilverlightToolkit\Tools\v3.0)Microsoft.Silverlight.Toolkit.Build.targets" />
<Import Condition="$(SilverlightVersion)=='v4.0'" Project="$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SilverlightToolkit\Tools\v4.0)Microsoft.Silverlight.Toolkit.Build.targets" />
|
|
|
|
|
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')
|
|
|
|