How to focus an image in Silverlight? - c#

How to focus an image in Silverlight?
For example: imagine that when my page loads, It will focus on a texbox, so I don't have to click in there to control. I want the same with image control.

There is no way for an Image to acquire input focus directly.
Input focus is supported only on Controls and its descendants which have the properties IsEnabled and IsTabStop set to true. Image is derived from FrameworkElement, not from Control, so it's not technically a control.
You could create a UserControl that contains the image and then call .Focus() on the container control.

It sounds like you want to make a button of the image and than set the button with the default focus.
Make a button with an image
Set button with focus

Related

I can not put the image below the text in TabPage headers

Can you help me, I have a TabControl but I can not put the image below the text carries the headertab any ideas?
I use c# and winform
To assign Images to TabPages, you can drop an ImageList on designer and add images to it, then select your TabControl, select ImageList property and set it to the image list you created. Then select TabPages property and edit tab pages, for each tab page, select an ImageIndex to show image before text.
But you should know TabControl doesn't have built-in support for images below/above text automatically, To do so, you should use Owner Drawn TabControl. You should set DrawMode property to OwnerDrawFixed and then handle DrawItem event and draw tab pages yourself.

move into next field webbrowser control

I am using a web browser control in wpf to load a web page. I need to have a wpf button which when clicked will help the user to move next input field, The web page have two text box and two radio buttons as input fields. How can i simulate this when the wpf button is clicked?
To set focus on a WPF textbox you can do as following. (Possible duplicate : source)
To set logical focus to an input control
FocusManager.SetFocusedElement(this, textboxJack); // set logical focus
To set keyboard focus to an input control
Keyboard.Focus(textboxJill); // set keyboard focus

HOW to set Focus on a hidden Textbox

In my page_load event I have this code :
myTextbox.focus().
So when I set my textbox to visible=false my code doesn't work.
Hidden controls are not focusable. Set the Opacity to 0 instead.
You cannot. If something isn't rendered, it cannot be interacted with, so you cannot set the focus to it.
Focus means that user input is focused to the control, that means if the control is a text-box, the text input cursor will be placed in the control or if it is a checkbox, the checkbox will be focused and may be selected by pressing space, you can't put a text input cursor in a hidden control and it cannot be used for any user input.
If you still want to set focus for some reason, try setting its height and width to Zero.
Like style="height:0px; width:0px"
and use Page.SetFocus(yourControl); to set focus
When you set the Control.Visible property to false it doesn't just hide the control on the page. It omits that control from being rendered on the client's browser entirely, but "remembers" everything about that control on the server for future postbacks.
If you actually do a client side hide (i.e. set the CSS Style display: none; then it will still exist on the page, but just be hidden. At that point you can focus it.

How does ToolTip show Popup on a control?

When set a TooltipText on a control, and the tooltip text will be shown when user move mouse on the control. Tooltip will detect MouseEnter or MouseLeave or anything for this purpose?
I want to know how does a Tooltip show Popup on a control?
Assume that I have a user control with name 'UserControlX'. On UserControlX, I put a button and set Dock property to Fill. I add a UserControlX on Form1, add a ToolTip and set a text to this usercontrol. ToolTip will be not shown when user move mouse on control because user is moving mouse on usercontrol's button, not usercontrol, so the tooltip will never show.
Please help me how to solve this problem so that when move mouse on UserControlX, the tooltip will be shown. Thanks.
I believe the tooltip displaying on mouse-over is defined within the control's default template. if you view the default template you will likely see a reference to a tooltip in there. If you go further and view the Tooltip's default template, you will see how it is composed as well as what events it listens to.
To answer your question, you could do what Adrian suggests and put the tooltip on the button as well as the parent control.
If you have time to mess around a bit, you COULD try to see if there is a tooltip displayed event or something to that effect for the button, and then simply invoke the parent control's tooltip manually. It could be considered a hack, but worth a try, maybe.

Issue with WPF Keyboard Focus in itemControl

I have a WPF window which is divided into two portions. One portion contains itemscontrol which generate textboxes depedning on observable collection binding in ViewModel.
The other portion of window has a content control which loads a usercontrol using datatemplate and viewmodel binding. Also that user control has buttons on it.
The problem is i want to keep keyboard focus within the textboxes in itemscontrol at all times and don't want the keyboard focus to shift to the usercontrol button even if they are pressed.
Currently the keyboardfocus shift from the text boxes to the usercontrol buttons when the button is pressed.
Is there a way i can keep keyboard focus in textbox in itemscontrol.
Setting Focusable="false" on the buttons should be sufficient.
I am just shooting in the dark, but here is something you can try: in your user control set Focusable to false and FocusManager.IsFocusScope attached property to true.
What about changing the focus back to the textbox in the button click event?

Categories

Resources