|
When you work with Storyboards in code you need to use RegisterName. You can learn more about the "why" here:
Storyboards Overview (MSDN)[^]
LinearGradientBrush mask = new LinearGradientBrush();
GradientStop transparentStop = new GradientStop(Colors.Transparent, 0);
GradientStop visibleStop = new GradientStop(Colors.Black, 0);
mask.GradientStops.Add(transparentStop);
mask.GradientStops.Add(visibleStop);
this.OpacityMask = mask;
NameScope.SetNameScope(this, new NameScope());
this.RegisterName("visibleGradientStop", visibleStop);
DoubleAnimation visibleStopAnimation = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1), FillBehavior.HoldEnd);
Storyboard story = new Storyboard();
story.Duration = TimeSpan.FromSeconds(1);
story.Children.Add(visibleStopAnimation);
Storyboard.SetTargetName(visibleStopAnimation, "visibleGradientStop");
Storyboard.SetTargetProperty(visibleStopAnimation, new PropertyPath(GradientStop.OffsetProperty));
story.Begin(this);
|
|
|
|
|
Thank you gurge60, that solved my problem.
|
|
|
|
|
Hello All, I'm kinda new in this field and want your help.
The problem is, that I want to create a custom treeview and I want that treeview to take it's template ,styles and setters from a dictionary, and do that in a "WPF CustomControl Library" (project type)
how can I do That ?
Thanks in advance
|
|
|
|
|
Do you have Blend? When you create a template Blend asks you where you want to define it. You can then choose to define it in a resource dictionary.
If not using Blend, I think you just define the template or style in the resource dictionary, then reference it in the XAML.
|
|
|
|
|
Hi there,
first of all: I'm quite new to WPF. The current project is to help me learn working with it.
I'm trying to make a window that is much like an ICQ window: http://bb.nfshost.com/icqNormal.jpg[^].
Items in there shall be collapsable like this: http://bb.nfshost.com/icqCollapsed.jpg[^]. I'd like to use Expander to achieve this.
Now, on to my problem(s). I want it all to size to the content. For the main window that's simple, as I found the SizeToContent="WidthAndHeight" property.
For the rest, well, I was trying around a few hours without any working results. Currently, my XAML looks like this:
<Grid>
<DockPanel Margin="0,0,78,0" Name="dockPanel1" VerticalAlignment="Top">
<Expander Header="test 1" Name="expander1">
<Grid>
<StackPanel Name="stackPanel1">
<Label Height="28" Name="label1" Width="120">Label2</Label>
<Label Height="28" Name="label2" Width="120">Label2</Label>
<Label Height="28" Name="label3" Width="120">Label2</Label>
<Label Height="28" Name="label4" Width="120">Label2</Label>
</StackPanel>
</Grid>
</Expander>
</DockPanel>
<DockPanel Margin="0,0,78,169" Name="dockPanel2" VerticalAlignment="Bottom">
<Expander Header="test 2" Name="expander2" VerticalAlignment="Bottom">
<Grid>
<StackPanel Name="stackPanel2">
<Label Height="28" Name="label5" Width="120">Label 0</Label>
<Label Height="28" Name="label6" Width="120">Label 0</Label>
<Label Height="28" Name="label7" Width="120">Label 0</Label>
<Label Height="28" Name="label8" Width="120">Label 0</Label>
</StackPanel>
</Grid>
</Expander>
</DockPanel>
</Grid>
Note: The content is supposed to be unknown, and variable in size.
What this sadly does, is put both expanders in the same place, covering each other. Anyone there who might help me out?
Thanks in advance
|
|
|
|
|
Well, this works for me:
<StackPanel Orientation="Vertical">
<DockPanel Name="dockPanel1" VerticalAlignment="Top">
<Expander Header="test 1" Name="expander1">
<StackPanel Name="stackPanel1">
<Label Height="28" Name="label1" Width="120">Label2</Label>
<Label Height="28" Name="label2" Width="120">Label2</Label>
<Label Height="28" Name="label3" Width="120">Label2</Label>
<Label Height="28" Name="label4" Width="120">Label2</Label>
</StackPanel>
</Expander>
</DockPanel>
<DockPanel Name="dockPanel2" VerticalAlignment="Bottom">
<Expander Header="test 2" Name="expander2" VerticalAlignment="Bottom">
<StackPanel Name="stackPanel2">
<Label Height="28" Name="label5" Width="120">Label 0</Label>
<Label Height="28" Name="label6" Width="120">Label 0</Label>
<Label Height="28" Name="label7" Width="120">Label 0</Label>
<Label Height="28" Name="label8" Width="120">Label 0</Label>
</StackPanel>
</Expander>
</DockPanel>
</StackPanel>
|
|
|
|
|
Or you could put it in a Grid and get rid of the VerticalAlignments:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" Margin="0,0,78,0" Name="dockPanel1" >
<Expander Header="test 1" Name="expander1">
<Grid>
<StackPanel Name="stackPanel1">
<Label Height="28" Name="label1" Width="120">Label2</Label>
<Label Height="28" Name="label2" Width="120">Label2</Label>
<Label Height="28" Name="label3" Width="120">Label2</Label>
<Label Height="28" Name="label4" Width="120">Label2</Label>
</StackPanel>
</Grid>
</Expander>
</DockPanel>
<DockPanel Grid.Row="1" Margin="0,0,78,169" Name="dockPanel2" >
<Expander Header="test 2" Name="expander2" >
<Grid>
<StackPanel Name="stackPanel2">
<Label Height="28" Name="label5" Width="120">Label 0</Label>
<Label Height="28" Name="label6" Width="120">Label 0</Label>
<Label Height="28" Name="label7" Width="120">Label 0</Label>
<Label Height="28" Name="label8" Width="120">Label 0</Label>
</StackPanel>
</Grid>
</Expander>
</DockPanel>
</Grid>
modified on Wednesday, March 25, 2009 6:52 PM
|
|
|
|
|
Hi,
I tried to use ApplicationCommands.Paste for a web browser application but it doesn't work. I used this command for window application and it worked. Is there anyone who has an idea to solve this problem. Thanks.
|
|
|
|
|
This is not a paid support forum - please don't attempt to push your post to the top when you've published the same one so recently. It's not good form.
|
|
|
|
|
If you dont have an answer why are you making comment. I am aware this isn't a paid support forum. I just want to solve a problem and get some help. I dont get what is wrong with it.
|
|
|
|
|
The etiquette of the forum is that you don't bump posts. The reason that people haven't answered your original post can be many and varied, perhaps the person who can answer it hasn't got round to viewing it yet, or perhaps the wording isn't done particularly well and people can't understand it, or perhaps somebody is putting text together to answer it, but hasn't gotten around to post a sample yet.
In any of these cases, you are doing other posters a disservice when it comes to your bumping your post. Suppose everybody decided to do this - it would become impossible to answer questions properly because you couldn't get a dialogue going with somebody because their post would disappear under a blizzard of crap.
|
|
|
|
|
OK, I have to admit that this makes me a bit, well, ticked...
How is something that is supposed to be a web technology for up-to-date cool looking web stuff lacking these features:
1) The ability to send an email without having to drop down and write a web service to do it?
2) The ability to post a blocking and modal dialog box to the user.
Geeeeeze...
And I was really starting to like Silverlight...
|
|
|
|
|
Ray Cassick wrote: 1) The ability to send an email without having to drop down and write a web service to do it?
Silverlight is client-technology. It runs on the browser. Can you send a mail from Javascript without using web service, web server or ActiveX object??
Ray Cassick wrote: 2) The ability to post a blocking and modal dialog box to the user.
I'm not sure what you meant.
|
|
|
|
|
Michael Sync wrote: Silverlight is client-technology.
OK, I can kind of get that aspect of it now... I guess my problems were partly my ignorance of the technology there. It is still sinking in...
|
|
|
|
|
About e-mail you have to go WCF and then in the server side use that service. Even if you could send an email to an SMTP server from silverlight you would have to set your credentials in your client code... this means... an spammer would be quite happy to dessasembly your code get the credentials and use them to rely on your SMTP and send tones of nonsense emails.
On the other hand, you create modal popups (I used them on my app), the result that you get is similar to the AJAX ASP .net modal popup.
Thanks
Braulio
/// -------------------------
Braulio Díez
DBSchemaEditor.com
Free Silverlight based DB Schema Modeling Tool
/// -------------------------
|
|
|
|
|
|
Ok, so I know how to bind to a collection (of course using an "observable collection" like any proper WPF gentry). However, supposed I want to bind a control to just one object that is not a collection.
Say for instance, I just want to bind the customer's information to a control so that they can see their name, address, phone numbers, and make any changes they desire. This does not require a collection of objects, just one Customer object. So, since it's one object, how do I ensure, for example, two-way binding so that whatever they change is updated? Or does it do this automatically for binding to one object?
Also, is it possible to bind to a property of an object? I have a user control (LittleControl) that is part of another user control (BigControl). If I bind BigControl to Customer, can I bind LittleControl to Customer.Benefits? How do I do this in the XAML?
Thanks in advance.
Blitz
|
|
|
|
|
It's easy to bind to a single item (and to ensure two way binding). All you need to do to the object is ensure that it uses INotifyPropertyChanged to raise notifications when properties change. If you look at this[^] blog entry, you can see how I bind to a simple class - it really is very straightforward.
BlitzPackage wrote: Also, is it possible to bind to a property of an object?
Yes. In your case, LittleControl "belongs" to BigControl, so LittleControl is able to walk all the way back up the logical tree looking for the data context, and use this to bind to the object. This means that it can use {Binding Path=Customer.Benefits} .
|
|
|
|
|
So, just to be sure - LittleControl can have its data context set to Customer.Benefits and thus, for example, bind one of it TextBoxes to Benefits.ProviderName - right?
Thanks again,
Blitz
|
|
|
|
|
How about I knock up a sample tonight, and post it on my blog for you to have a look at. Would that help at all?
|
|
|
|
|
Thanks Pete - I owe you one. That would help plenty.
|
|
|
|
|
|
OMG! That's awesome Pete! You have inspired me to start looking at putting up a blog. I would really love to share what I know with the world.
Thanks for the information. It's very, very helpful.
Blitz
|
|
|
|
|
You're welcome. Blogging is really good fun.
|
|
|
|
|