I have a Canvas and in it a Border. Now I want to give focus to this Border.
Can somebody please tell me how do do this?
First, make sure you have Border.Focusable = True. After that, just call Border.Focus() and you should be good to go.
I haven't tried it for Borders, but with a WPF ContentControl, I think I had to set IsTabStop and IsEnabled to true to get it to be able to accept focus.
Related
I need to show a Tooltip on some disabled ContextMenu items. I tried the workaround using borders and putting the Tooltip and menu item in the borders, but my menu design completely messes up, setting Margin, Padding and BorderThickness to 0 doesn't help.
Any ideas ? Another approach ?
Thanks in advance
Ok, i got it, thanks to vinod8812.
I gave my MenuItem a style with different VisualStates, then i just needed to change the VisualState of my MenuItem to "Disabled", the tooltip works fine.
VisualStateManager.GoToState(menutitem, "Disabled", true);
Not a perfect solution, but will work so far.
Is there a way to get focus on both controls in the WPF DatePicker? Setting the Focusable property on both makes neither work.
We would like users to be able to tab to both controls instead of focus only going to the textbox. Thanks!
I got some help on this. I needed to set the KeyboardNavigation.TabNavigation property to "Continue", then it worked. Thanks to Sam for the fix.
I would like to move a StackPanel horizontally when the user clicks a button. I'm implementing DoubleAnimation with TargetName and TargetProperty. But, I don't know which TargetProperty to use.
Can anyone help me?
If you put the StackPanel inside a Canvas you can achieve this behavior by setting the Canvas.X and Canvas.Y properties. Alternatively you could animate the Margin of the StackPanel by using ThicknessAnimation. Check out this post for a similar request.
Another method would be a TranslateTransform applied to the RenderTransform of the StackPanel. The TargetProperty path for the animation then would be RenderTransform.X.
Hi
I am trying to render buttons as the item template of a list, to be displayed horizontally. The problem is that they don't 'butt up' to each other. They leave a small gap betwen each one. I have tried allsorts of things to cure it, but have'nt succeeded.
Any ideas?
Try using the WPF tool Snoop to work out where the margin is coming from, and then fix it.
(Negative margins = code smell, in general, IMO.)
Try a negative margin, setting cliptobounds to false, maybe that can help
It's most likely either a Border, Margin, or Padding on your item container (i.e. ListBoxItem if you're using ListBox) which can be corrected with the ItemContainerStyle or your Button's Border is using BorderThickness=1, BorderBrush=Transparent or null.
Use Snoop as Dan suggested to find out.
in above image you would notice that, doted rectangle indicating ComboBox is focused
But the problem is it exceeding the text area of ComboBox... how do I align it with text area WPF Style?
Thanks
Without seeing your ControlTemplate it's difficult to give the best way to change it.
One slightly hackish way to do it is set Focusable on the ComboBox to False and then set Focusable on the TextBlock (or Label) to True. This should make it so the TextBlock gets focus whenever the ComboBox should.
My best guess though is that you have some weird margins going on, the real way to fix it would be to straighten those out.