|
If you succeeded in getting a service reference then you are halfway there.
Let's say you saved that reference as MyWcfService. That name becomes your namespace extension. So if your project is MyWeb, then your full service namespace is MyWeb.MyWcfService.
In your program you now have to find the name of your DataClient. After that the rest is a piece of cake.
MasterClient client = new MasterClient();
client.OpenAsync();
client.GetInformationEventHandler+=new EventHandler(ProcessResults);
client.GetInformation();
client.CloseAsync();
The event handler sets the CallBack from the asynchronous call.
The GetInformationI() call is actually whatever your calls are in your service. (event handlers are automatically generated for you)
You can make multiple calls to multiple methods on the same instance of the client. But if you have to make two calls to the same method, you need two separate instances of the client and two instances of the event handler. (such as loading the customer address and billing address)
|
|
|
|
|
I have created WCf services in console Application in C#. How can i use this services in silverlight .web part.using this services i have to display data.
|
|
|
|
|
You have already posted this question here.
Please do not repost....
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I wish to bind 'Canvas.Left' of an ellipse to a property (iEllipse) of Class instance(bClass). This property gets updated from several locations. Following is the C# code:
namespace BindingTest
{
public class BindingClass
{
public int iEllipseLeft { get; set; }
public BindingClass()
{
iEllipseLeft = 30;
}
}
public partial class Window1 : Window
{
BindingClass bClass;
public Window1()
{
InitializeComponent();
bClass = new BindingClass();
}
private void updateLoc()
{
Random random = new Random();
bClass.iEllipseLeft = random.Next(0, 100);
}
}
}
And, this is the ellipse I want to bind. Basically I want to move this ellipse whenever bClass.iEllipseLeft gets changed.
<Canvas Margin="16,128,244,52" Background="#FFE8E8E8">
<Ellipse Fill="#FFFE0C0C" Width="32" Height="32" Canvas.Left= "5" Canvas.Top="48"/>
</Canvas>
Whether it is possible by writing '{Binding=..}' in .XAML or by coding in .cs file, please let me know. I'll be happy in either way. It might be a very simple question, but I've just started using WPF and C#, so please help
|
|
|
|
|
Hi
Try declaring EllipseLeft as a DependencyProperty. Below is a sample code
public static DependencyProperty EllipseLeftProperty = DependencyProperty.Register("EllipseLeft", typeof(int), typeof(Window1));
public int EllipseLeft
{
get { return (int)GetValue(EllipseLeftProperty); }
set { SetValue(EllipseLeftProperty, value); }
}
Than you can set up the binding in the xaml.
I hope this helps
Uros
|
|
|
|
|
Got the answer. Thanks koleraba! Just adding few bits and adjustments to your code to make it run.
Inside class, we need to define property something like this:
public class BindingClass : DependencyObject
{
public static DependencyProperty EllipseLeftProperty = DependencyProperty.Register("iEllipseLeft", typeof(int), typeof(BindingClass));
public int iEllipseLeft
{
get { return (int)GetValue(EllipseLeftProperty); }
set { SetValue(EllipseLeftProperty, value); }
}
}
Also in starting, we need to set data context of the object/canvas or Window:
BindingClass bClass = new BindingClass();
objEllipse.DataContext = bClass;
And, in .xaml file:
in stead of
<Ellipse Fill="#FFFE0C0C" Width="32" Height="32" Canvas.Left= "5" Canvas.Top="48"/>
write
<Ellipse Fill="#FFFE0C0C" Width="32" Height="32" Canvas.Left= "{Binding Path=iEllipseLeft}" Canvas.Top="48"/>
That completes the binding!!
|
|
|
|
|
I have just installed Silverlight 4 and all that other stuff from Microsoft because I wanted to use this technology on my web building, but I have never programmed in C#, Silverlight, .Net... I am used to html and css basics. Mainly building with Dreamweaver. (I want to expand my horizons) Now that I have have Silverlight, I am thinking of a website.
This website will be a carousel with 5 pictures of differnt pages from the site. Just needs a left/right control, each pic is a link to their repective pages, and I would be using a picture for the background.
If anyone can help me with this, I would truely appreciate it..
P.S. I have done a lot of research on many other sites, but they all have controls, needed assemblies.. Stuff I don't know about or don't know how to modify to my needs.
I need someone who can help me thru the process.
|
|
|
|
|
|
If you are a beginner, you should have a look at the two videos posted here.
|
|
|
|
|
I have seen those 2 pages, and it is way off of what I would like, and I don't have the knowledge to modify what he does...
And the other poster: While his work looks real nice, and is similar to what I want, his tutorial is just above my comprehension...
*sigh...
It might be no use to me anyhow as GoDaddy has a problem with Silverlight working under IIS 7, contrary to what they post.. And some of the fix arounds have been no help because they too are confusing and GoDaddy doesn't have the proper GUI controls.
|
|
|
|
|
Hi All,
I wondered if someone could help me, to add additional parameters to a Style.
I've currently got a ContentControl, which has obviously has a "Background", "BorderBrush", "Foreground" & "Opacity Mask" brushes in the Properties tab. And I would like to specify additional brushes, that are contained within the Style.
The reason I want some additional brushes, is to define some Gradient Brushes. That I am using as an overlay for some of the components/parts of my inherited Control.
I can't seem to find anything on the web, but maybe I'm not looking in the right places!
One last thing, I'm a designer not a developer. - So presume I'm stupid to save time!!! ha ha
Thanks in advance!
Alan
|
|
|
|
|
What you could do is to bind your color to a property of your datacontext - something like -
<textbox x:name="MyTextBox" text="Text" foreground="{Binding Brush1, Mode=OneWay}">
You can then set your color through the code.
You could probably talk to a developer to see if this approach is useful to you.
|
|
|
|
|
Thanks, but I obviously did not make it clear:
I want to see this new brush, in the brushes section of the Properties tab of Expression Blend.
Something like this:
http://www.infragistics.com/uploadedImages/VDG/Blend_custom_brushes.jpg
Thanks anyway.
modified on Monday, March 22, 2010 1:33 PM
|
|
|
|
|
Not sure, but maybe this[^] video may be of some help to you.
|
|
|
|
|
Thanks, but that still does not address or answer my question.
|
|
|
|
|
Hi Alan, you have probably figured this out by now. I haven't used Blend much but I think what you are looking for is that once you define your brush in Blend under properties, you can then click that tiny square 'advanced property options' and select 'Convert to new resource' which will then give you options where you want to place the brush. You will then have your new brush available under 'Brush Resources'.
|
|
|
|
|
Hi Katka,
Thanks for having a look at this, but it's a coding issue. (I am 99.99% sure!)
I actually wanted this for my Picture Frame tutorial[^] to make it a bit funkier. And the reason is best explained there. I did drop a few hints, but no developer has taken the bait yet!
Cheers,
Alan
|
|
|
|
|
Hi Alan,
I will have another crack at this
You can add brushes to your style by addig them to your Resource Dictionary. Then you will have them available in Blend under 'Brush Resources'. For example if I were to add the six brushes, shown below, to the resource dictionary (PictureFrames.xaml) of your Picture Frame project, I would have all these brushes available in Blend under Brush Resources as shown here http://prikl.com/brush-resources.gif[^]
<!-- Primary Color Brushes -->
<SolidColorBrush x:Key="NavigationBackgroundColorBrush" Color="#FF282828"/>
<SolidColorBrush x:Key="NavigationForegroundColorBrush" Color="#FF595959"/>
<SolidColorBrush x:Key="HighLightColorBrush" Color="#FF747474"/>
<SolidColorBrush x:Key="HoverHyperlinkForegroundColorBrush" Color="#FFEBF7FF"/>
<SolidColorBrush x:Key="HoverHyperLinkBackgroundColorBrush" Color="#FF0096FF"/>
<SolidColorBrush x:Key="BodyTextColorBrush" Color="White"/>
Is this what you were after?
|
|
|
|
|
Thanks Katka, unfortunately not!
As what I really want, is an extra Brush built into an inheritied Content Control. And then to convert this brush (on the fly) to 2 different resources (One of them rotated 90 degree)
This would allow me to edit the profile of my picture frame control in one spot, for both the Horizontal & Vertical Gradients. As currently, I have 2 resources that I reference. (just as you show)
Referencing 2 separate resources, means I have to copy setting from one to another...
It would just be really sweet to have this built in, as I'm finding this Control really handy, as you will see in my next tutorial...
Thanks for looking at this
Alan
|
|
|
|
|
I'm developing a WCF service and a client in a solution and when I use a service reference to the WCF in the solution that is added with FilePath (not IIS) everything works fine. However when I try to either add the service as an IIS website, or I publish the service then host under IIS and then add the reference, I'm getting the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: Object reference not set to an instance of an object.
|
|
|
|
|
There's not a lot of help that we can offer you here I'm afraid. As you are already aware, this means that you are attempting to access a property/method on an object that is null. The details of where the exception is really happening will be in the InnerException, so that's where you need to look.
"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
|
|
|
|
|
Ye trying to fix. will post the resolution when am done in case it helps anyone someday !!!!
Thanks anyway
|
|
|
|
|
Also add includeExceptionDetailInFaults attribute if you haven't.
Kevin
|
|
|
|
|
Using this excellent article[^] I am trying to set up a custom binding extension. The issue is that when the binding finds the source object, I need to do some stuff to the source object, but I don't know where to put that code. For example, I have the following class:
class MyObject {
public string Value { get; set; }
}
and some XAML in MainWindow.xaml:
<Button Content="{my:CustomBinding Value}">
And set the data context in code:
public MainWindow()
{
InitializeComponent();
this.DataContext = MyObject;
}
That much works, the Value string gets displayed on the button. But what I need to do is write code in the CustomBinding class that operates on MyObject as soon as possible, which means I need to resolve MyObject from the BindingExpression.
What I've figured out so far is that when the CustomBinding instance is created, it doesn't actually find the MyObject.Value because it needs to find the data context first in order to resolve the BindingExpression, so it doesn't actually find MyObject until the MainWindow gets laid out on screen.
So my question is, what code do I write in the CustomBindingExtension class so that it runs when the WPF layout system decides to resolve the BindingExpression to find MyObject?
|
|
|
|
|
For anyone interested, the answer turned out to be to hook into the DataContextChanged event of the targeted UI element (button1.DataContextChanged in this case).
|
|
|
|