|
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?
|
|
|
|
|
It is an OS setting for keyboards. See here[^]
|
|
|
|
|
Thank u very much... Its working fine..,
|
|
|
|
|
I have a ProgressBar control in a Window , and the ProgressBar is bound to a property in the window. A DispatcherTimer is used to count down seconds, and sets the bound property to the current value.
Setting the initial Value works fine, but subsequent settings don't seem to have an effect. I know the timer is ticking because there's also a countdown clock on the window as well, and it's counting down properly.
What am I doing wrong?
---------------
Resolution
---------------
I'm not sure why, but binding the Value property does not work. You actually have to set the Value property from within your code. While this is "okay" as a workaround, it seems strange to me that binding does not work here.
Any Comments?
"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
modified on Friday, June 5, 2009 12:31 PM
|
|
|
|