I'm making a Windows Store app in C# and I have a normal TextBlock with a link inside it. And all I want to do it to make the cursor change into a hand when it goes over the text block, but unlike in WPF applications, there is no Cursor propriety. I know is a CoreCursor class in Windows.UI.Core. Am I suppose to use it somehow?
Window.Current.CoreWindow.PointerCursor =
new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);
WinRT XAML Toolkit has an attached property that works just about the same as the Cursor property in WPF in that you set a cursor for an element and so when your mouse cursor hovers on top of that element - the cursor changes to what the property specifies and when it leaves control bounds - it restores the previous cursor. There are actually two properties - one called FrameworkElementExtensions.SystemCursor that takes any standard cursor from the CoreCursorType enum, which you just use like in this sample page - set
<Border
xmlns:Extensions="using:WinRTXamlToolkit.Controls.Extensions"
Extensions:FrameworkElementExtensions.SystemCursor="Cross"/>
The other one - FrameworkElementExtensions.Cursor allows you to set any custom cursor, but I believe you'd need to set it in code behind like FrameworkElementExtensions.SetCursor(myElement, myCursor); or bind to a cursor property set elsewhere.
You can also use custom cursors. You need to define a cursor in a native resource library as described in this article and then you should be able to set them either globally by setting the Window.Current.CoreWindow.PointerCursor property or with an attached property like my FrameworkElementExtensions.Cursor.
Related
I need to display a tiled image as BackgroundImage in a RadSplitButton, but when I set the BackgroundImage property it is ignored by the control
In the other hand, the Image property works as normally, but I need to set the BackgroundImage property.
Why this property is ignored by default, and how to fix it?.
RadSplitButton is in fact built of three different elements - action button, separator and arrow button. Each of these elements is built of other elements (fills, borders, etc). All controls in the suite are built with the Telerik Presenation Framework and consist of multiple elements to allow greater flexibility. This way for example you can set different image/color for different elements - action part and the arrow part of the button.
In this case, the BackgroundImage is painted on the control, however, the element's fills are painted over it, hence it is not visible. Here is how to hide the fills in order to see the BackgroundImage:
radSplitButton1.DropDownButtonElement.ActionButton.ButtonFillElement.Visibility = ElementVisibility.Collapsed;
radSplitButton1.DropDownButtonElement.ArrowButton.Fill.Visibility = ElementVisibility.Collapsed;
radSplitButton1.DropDownButtonElement.ButtonSeparator.DrawBorder = false;
I see that you also want to see the theme. This however, would not be possible as you cannot see both the image and the fill, as if you see the fill, the image is hidden. Perhaps you can use the MouseEnter and MouseLeave event to apply different image for hover?
I have a custom control. Can I show tooltip where I want and when I want? TooltipService and Tooltip classes don't help me, because don't contain appropriate members. Is there another way to implement custom tooltips?
Note that the ToolTip can be opened programmatically by setting IsOpen, and besides the top/left/bottom/right placement modes which are ideal for touch users, the mouse placement mode can position a tool tip relative to the touch/mouse point. If the provided tooltip placement modes don't suffice for your scenario, use a Popup (ToolTip uses one under the hood).
In my application, there are two instances where I would like to use a non-default cursor.
One is on a panel which the user may "draw" on using the mouse. I would like to change the cursor from the default mouse to a pen or paintbrush. I would like to get an image from online, convert it to the appropriate filetype and use it as my cursor for the panel.
The other instance is when an image is added to a rich text box. I would like to add the correct "resize" arrows so that when the user hovers the mouse over one of the small black boxes, the cursor changes to the double arrow (like in other programs).
How easy is this to achieve?
I don't have a clue where to start when it comes to implementing the resize arrows, as there isn't always an image in the rich text box (only when the application is being debugged or used).
There is actually a cursor option for winforms in the properties tab, you could change the cursor whenever the Cursor.Position is equal to the item's position.
Even better, use the MouseHover event and add a new handler to change the cursor when it is called.
All of the controls in WinForms have a Cursor property, since they all inherit from System.Windows.Forms.Control. Whatever cursor you assign to this property will be displayed automatically when the mouse pointer is over that control.
This is an ambient property, which means that it automatically inherits its value from its parent (for example, a Button control would automatically use the same cursor as its parent form) unless it is explicitly set otherwise.
So to change the cursor displayed over a certain control, all you need to do is set that control object's Cursor property. The framework will take care of the rest.
how can i make a text moving from top to bottom to top.... (like a news window) in a textBox
(Assuming windows forms)
I haven't tried to do this before, but my first attempt would include loading a bunch of text (like new headlines) into a textbox, and then making a timer that changes the vertical scroll value on the tick event? A textbox has built-in functions called ScrollToLine(), ScrollToVerticalOffset(), etc. Otherwise some controls, like panels have more direct access to scrollbar values. For example: SplitContainer.Panel1.VerticalScroll.Value = value;
If those don't work, you can always draw the text yourself via graphics object and then update the positions items are drawn at.
you can use javascript to do it for web and if it is windows have a look at this question . Hope it helps
I feel quite limited by the default ContextMenuStrip, as it only can contain buttons, and no Controls.
I was wondering that for a long time, and I already tried it, using forms, but it never really worked out.
I already have I idea on how to set the whole thing up, with events and items. The only problem I have is the paint method.
When you open a ContextMenu (ContextMenuStrip) you can set its position on the mouse cursor, and it will be there, even if that means that it goes beyond the active form. (So I can't use the Controls Class as inheritance, as they can only draw themself as a part of a form.
Now I thought to use the Form Class as a base for my ContextMenu, but those where placed on the screen randomly.
So what I actually need is a class (or something similar) that can draw itself, without problems, and can be placed accurately on the screen.
Any hint would be nice, thanks.
Greg the Mad
Your first statement is false -- you can have a TextBox or a ComboBox in a ContextMenuStrip.
MSDN ToolStripComboBox
MSDN ToolStripTextBox
From the designer there is a small drop-down arrow when your mouse is in the "Type Here" box (sometimes hard to click) that will allow you to change the type.
If you are looking to allow for any type of control to be displayed in a top down fashion inside of a container to be positionable... you could always make a custom control using FlowLayoutPanel. With it's properties FlowDirection=TopDown and WrapContents=False to keep a vertical approach. This will handle your "menu" basics and your new control can expose whichever events you wish from each Control. You will have to handle the logic of showing the panel and positioning with it's Location property as well.
I forgot to address the issue with drawing outside of the parent form. Notice that ContextMenus are smart and when they reach a boundary of their parent they draw away from it. You should logically be able to draw in the correct direction (Up/Down or Left/Right) from any right mouse click. Per your attempt with a Form, set StartPosition=Manual then prior to calling Show() or ShowDialog() set it's Location property respective to the X and Y parameters provided in the event args of MouseClick.