|
I have to use the designer to at least get initial layout accomplished. It's simply impossible to do layout without the designer. Many times, I just manually edit the XAML, but if there's a property in the pane, it's much faster just to set it and let the IDE do the typing.
Truth be told, anyone just starting out with WPF will also start out with the designer, simply because it's easy to see what's generally available as far as properties are concerned.
Lastly, even the intellisense in the XAML editor won't help you if you don't know you can type a dot and get more functionality. Admit it - the IDE bites, and I have yet to find a basic "WPF does it this way" kind of document. I wonder if there's a "WPF for Dummies" book out yet. I could certainly make use of it.
And if you want to hear something scary, I'm the resident WPF expert at work. If I don't know the answer, they have to hit google (just like me).
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Lastly, even the intellisense in the XAML editor won't help you if you don't know you can type a dot and get more functionality.
There's no magic in there.
It isn't any different than using .NET classes from code - you need to know the
data types of the properties you're using, and the public framework classes are well
documented. XAML throws a new language into the mix, so if you choose to use XAML
to set properties, you need to know the syntax for setting properties of the types
you use.
I highly recommend to anyone committing (or being forced to commit) to using WPF, to do
what I did...
1) open up the documentation
2) navigate to the WPF SDK (.NET Development/.NET Framework SDK/.NET Framework 3.5/Windows Presentation Foundation)
3) read it ALL - all of it - do not skip anything.
4) repeat step 3, this time trying some of the stuff you're reading about
5) (optional) if one is not a seasoned .NET programmer, one may want to invest in a book or two that breaks stuff down in simpler terms
It'll save you so much time down the road having a familiarity with how things work and
knowing where to find answers, instead of having to always weed through tousands of often
half-assed or completely wrong answers found via Google.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
John Simmons / outlaw programmer wrote: Truth be told, anyone just starting out with WPF will also start out with the designe
Maybe it's my ASP.NET background that makes me the exception. I don't expect too much from the IDE, I know better. The initial WPF support was shaky as hell, you think this is bad now ?
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Christian Graus wrote: When you specify a margin, you provide one, two or four values. If you provide one, it's used for all sides. If you provide two, one is used for top/bottom, the other for left/right. If you provide four, then you are specifying a thickness for each side explicitly.
BorderThickness, not Margin.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
*sigh* close, but no cigar....
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Christian Graus wrote: When you specify a margin, you provide one, two or four values. If you provide one, it's used for all sides. If you provide two, one is used for top/bottom, the other for left/right. If you provide four, then you are specifying a thickness for each side explicitly.
What Christian meant is BorderThickness, not Margin.
For example, for a border thickness of 2 with the top thickness 0:
<Border Width="100" Height="50" BorderBrush="Red" BorderThickness="2,0,2,2" />
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In my project I'm trying to get the mouse over an image and use the CaptureMouse event to move the image when I move the mouse. I'm able to move the image in the same direction as the mouse but the mouse isn't directly over the image. Here is what I have in my xaml file:
<Image Margin="116,76,113,176" Name="image1" Stretch="Fill" MouseLeftButtonDown="image1_MouseLeftButtonDown" MouseMove="image1_MouseMove" >
<Image.RenderTransform>
<TranslateTransform x:Name="imageTransform" X="0" Y="0" />
</Image.RenderTransform>
</Image>
Note: The image is inside a simple grid tag.
In my image_MouseLeftButtonDown down event I have:
image1.CaptureMouse();
In my image_MouseMove event I have:
if (Mouse.LeftButton == MouseButtonState.Pressed)
{
test = Mouse.GetPosition(null);
imageTransform.X = test.X;
imageTransform.Y = test.Y;
}
Note: test is a Point datatype. The image follows the mouse but I can't figure out how to have the image follow the mouse when the mouse is over it. What am I doing wrong?
Terrance C.
|
|
|
|
|
Have you traced the mouse value you're getting ? I suspect the value you're getting is not absolute to your image. I would suggest storing the mouse position when you capture it, and on move, working out how far you've moved and moving the transform accordingly, instead of setting an absolute value.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Thanks Christian. When you say working out how far I've moved can you give an example? I understand what you're saying but not sure how to approach it.
Terrance C.
|
|
|
|
|
<Canvas Width="300" Height="200" Background="AntiqueWhite" >
<Image Name="image1" Source="images/Silverlight_Logo.jpg" Stretch="None" MouseLeftButtonDown="image1_MouseLeftButtonDown" MouseMove="image1_MouseMove" MouseLeftButtonUp="image1_MouseLeftButtonUp" >
<Image.RenderTransform>
<TranslateTransform x:Name="imageTransform" X="0" Y="0" />
</Image.RenderTransform>
</Image>
</Canvas>
Point anchorPoint;
Point currentPoint;
bool isInDrag = false;
private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
anchorPoint = e.GetPosition(null);
element.CaptureMouse();
isInDrag = true;
e.Handled = true;
}
private void image1_MouseMove(object sender, MouseEventArgs e)
{
if (isInDrag)
{
FrameworkElement element = sender as FrameworkElement;
currentPoint = e.GetPosition(null);
imageTransform.X += (currentPoint.X - anchorPoint.X);
imageTransform.Y += (currentPoint.Y - anchorPoint.Y);
anchorPoint = currentPoint;
}
}
private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (isInDrag)
{
FrameworkElement element = sender as FrameworkElement;
element.ReleaseMouseCapture();
isInDrag = false;
e.Handled = true;
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey, I'm working this side of the street !!!! :P
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
I had the code handy since I've posted it close to a million times.
The credit's all yours
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Dang, that was simple enough. Thanks, for the help; I greatly appreciate it.
Terrance C.
|
|
|
|
|
with this method, how can i move one of images .
the code below
imageTransform.X += (currentPoint.X - anchorPoint.X);
imageTransform.Y += (currentPoint.Y - anchorPoint.Y);
will affect all of the images.
|
|
|
|
|
Hi All,
Im using WPF application 2008. I need to Underline First Letter of Button Content.
For Example,Button content ="Save", Have to underline 'S'.
Can any one pls help me.
|
|
|
|
|
In WPF, "_" is used to represent a shortcut/access key.
e.g., "_Save"
|
|
|
|
|
This is part of Microsoft's ongoing campaign to "Change for the sake of change". Since 1990, we've used an ampersand (&) to indicate an underlined character, but for WPF, they changed it for no apparent reason to an underscore.
Way to gop Microsoft - make that learning curve as steep as possible.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: This is part of Microsoft's ongoing campaign to "Change for the sake of change". Since 1990, we've used an ampersand (&) to indicate an underlined character, but for WPF, they changed it for no apparent reason to an underscore.
They changed it because & isn't valid in XML. To display this in XML, you have to put in & and that's a lot more work than just using _.
"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
|
|
|
|
|
Pete O'Hanlon wrote: They changed it because & isn't valid in XML.
And who invented XML? Microsoft, obviously (it's the acronym - "Xperimental Microsoft Language"). IT'S A CONSPIRACY!
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
ROTFL !!! Yep, you're not bitter at all.
My good news is that an OSX update has killed directX support in my VM, so I can't do any WPF work on my main machine until ATI get their act together. As usual, VMWare are blaming everyone but themselves.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
You know, you should get one of those cheap Acer notebooks ($500-600) so you can still do work if you have problems on your Mac. My Acer ain't the most speedy thing in the world, but it has a dual-core AMD, 4gb of RAM, and a 250gb hard drive, and I use it for development on the road. It came with Vista Home Premium (32-bit), but I'm running XP-32 on it till Weven comes out. I think it cost me $549 at NewEgg (last year I think)...
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
I have a decent PC and a decent PC notebook in the house. What I lose, is OSX at the same time, which I've become accustomed to, AND none of them are as fast as my Mac, and I lose my desk/three monitor setup. Unless I strip down and retire my Mac in the meantime.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Hi All,
Thanks for reply.
I ve tried _Save option in button content,but it is not working. Could u suggest some other solution.
|
|
|
|
|
That should work. Your machine may have ALT as the access key. Hit the 'ALT' button after invoking the application.
Are you overriding the style/template of the button ?
|
|
|
|
|
Thanks.
Its working fine after hitting the ALT button.But i need to undeline the letter while running the application itself. Is there any properties for that?
|
|
|
|