I have an Image, which is attached to some JavaScript on MouseEnter.
This all works fine. When user "Mouses Over", JS is called and storyboard runs as expected.
I also want to change the mouse cursor to a "Hand Pointer" when the user hovers over, probably I guess, this occurs in the same JS function.
Also, how do I change it back?
Many thanks
Answering my own question again:
Turns out there is a Hand attribute I missed.
<Image Canvas.Left="719.732" x:Name="img17_18" Width="180" Height="208.09" Source="Padmamand1.jpg" Stretch="Fill" Canvas.Top="36.91" Opacity="0.595" Cursor="Hand"/>
Sweet.
Related
How do you create a control that horizontally scrolls the text to show text that are to long?
So instead of character overflow i would like it to scroll from side to side.
I've seen controls that does a continues scroll but that's not what i look for.
Not clear wih your Question. Something like this.
<TextBox Width="500" Height="50" ScrollViewer.HorizontalScrollBarVisibility="Auto"/>
Dont know where I have to put animation here :)
I'm using the Microsoft Ribbon for WPF October 2010 and have got 3 buttons next to each other, inside a RibbonControlGroup. The left and the right ones are text-only RibbonToggleButton controls, the one in the middle is an image-only RibbonButton. The buttons have a defined width to match the row above.
My code:
<r:RibbonControlGroup>
<r:RibbonToggleButton Width="110" Label="Outgoing" IsChecked="True" />
<!-- Padding and Height set to align the buttons/image -->
<r:RibbonButton Width="30" Padding="5 0" Height="24" SmallImageSource="Images\Small\arrow_swap.png" />
<r:RibbonToggleButton Width="110" Label="Incoming" />
</r:RibbonControlGroup>
The problem is that as soon as I apply the SmallImageSource to the middle button, the other two get spacings for images, causing the text not to be centered anymore. That is problem (1).
Because I didn't find a quick solution, I tried to add the image of the middle button not via SmallImageSource, but by adding it as <Image> for the content of the button. However, the button would remain empty. That is problem (2).
My third solution was to add images to the left and the right button, too. Unfortunately there is nearly no margin between the image and text, which looks quite ugly. I tried several things to enlarge the margin like adding a <Style TargetType="Image"> to the <RibbonToggleButton.Resources>, but although the editor accepts it and displays the spacing at designtime, the margin is gone again at runtime. That is problem (3).
Does anybody have an appropiate solution to any of the three problems? I cannot get it to work. The number of the problems is also the preference of the alternatives, (1) being the most favourite to use with an appropiate hack.
It seems you cannot do that. Its by design.
As per MSDN (here about half way down the page):
Related ribbon controls can be grouped together in a RibbonControlGroup. When a control group is resized, one RibbonControlSizeDefinition is applied to all of the controls in the RibbonControlGroup. The RibbonControlGroup is positioned in the RibbonGroup as if it were one control.
All the controls in a RibbonControlGroup shares the same RibbonControlSizeDefinition. Hence, in your case image will be added for all the buttons.
You may use RibbonGroup instead if you do not want to glue all your controls very closely. This way you can customize each button container by using different RibbonControlSizeDefinitions.
The ContextMenu provided by the Silverlight 4 Toolkit worked great until I implemented a
<RenderTransform> tag in my XAML in order to have the Silverlight app scale to fit the entire browser window (following this little tutorial)
When all worked great, before the tutorial, my XAML looked like:
<UserControl>
<Grid>
<!-- Rest of app here... -->
</Grid>
</UserControl>
Now, my app looks like:
<UserControl>
<Canvas>
<Canvas.RenderTransform>
<ScaleTransform [vars]></ScaleTransform>
</Canvas.RenderTransform>
<Grid>
<!-- Rest of app here... -->
</Grid>
</Canvas>
</UserControl>
The scaling works perfectly, but now when I right click, the ContextMenu doesn't appear where it should (under the mouse). Instead, it appears at the same x-position as the mouse, but it shows up at the very top of the app. It's also very buggy, I have to keep clicking around to get it to go away, and I can't right click somewhere else to bring it up again, and it doesn't scale along with the rest of the app.
What might be causing this? Is there a correct way to go about fixing this, or should I just apply an offset to the menu to move it to the mouse?
You will need to pass the cursor coordinates through the inverse of your scale transformation to convert the screen point to a point your application understands.
At some point in my app the main window closes and the application continues to run as a system tray icon.
Whenever this happens, I want to show the user, that the app is now in the notification area as an icon. I could just show a tooltip, but it's not cool anymore.
Instead, I want to levitate a big arrow over an icon, to be sure that the user sees it.
Here is how it's done in DropBox application:
http://img59.imageshack.us/img59/9364/arrowva.png
What is the best way to create and animate this arrow in WPF:
A custom shape window? If so, what will do the animation. Can I apply storyboard animation to a window itself?
A transparent larger window, but with arrow as an Image, and animate it with storyboard? But than, I will have the window capture mouse clicks, which is not desired.
Some other approach?
Thank you.
You can use Popup with explicit position:
<Popup AllowTransparency="True" IsOpen="True" Placement="AbsolutePoint"
HorizontalOffcet="{x:Static namespace:TrayInfo.LocationX}"
VerticalOffcet="{x:Static namespace:TrayInfo.LocationY}" >
<views:YourViewWithAnimatingArrowImage DataContext="{Binding ifYouNeed}" />
</Popup>
TrayInfo
since u can't really animate a window, (it's a user32 thing, not a wpf element), I'd go with option 2.
In my Canvas, I have an image object. I haven't set a source in it, but it has coordinates and a size. The tag is:
<Image Canvas.Top="50" Canvas.Left="20" Height="68" Width="110" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" />
Here's the problem: When I move the mouse over it, I want to find it. With this code:
VisualTreeHelper.FindElementsInHostCoordinates(point, Application.Current.RootVisual)
It won't find the image unless a source is set. If no source is set, then the image isn't returned. Does anyone know why? This is causing me problems. I have some drag/drop code and I'm looking to drop something on that Image control, but I need to know when the mouse is over it.
I know there are other ways I could do it (such as placing something else in that location, like a grid or something and detecting that), but that's not going to work. I can think of several ways that will work, but they're far less elegant.
If I could get the above to return my image, that would definitely be ideal.
In your code you had Point point = e.GetPosition(_canvas); This gets the MousePosition co-ordinates in relation to the canvas, but your second line VisualHelper.FindElementsInHostCoordinates(point,Application.Current.RootVisual) is searching in relation to the whole page. You need to change one or the other so they in relation to the same control. I would just change to VisualHelper.FindElementsInHostCoordinates(point,_canvas)
You can add a <Border> object around the Image object.
Or you can add eventhandlers for the mouseenter and mouse leave and change the Cursor.