Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Unassigned: DoubleUpDown (probably any UpDown) - problem with IsFocused [20785]

$
0
0
I can't find a way of getting IsFocused to trigger for a DoubleUpDown control. (In fact it looks like this problem applies to all the xxxUpDown controls).

e.g., the following code does not trigger a background change:
```
<Style x:Key="expNumUpDownStyle" TargetType="xctk:DoubleUpDown" >
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Purple" />
</Trigger>
</Style.Triggers>
</Style>

```

```
<xctk:DoubleUpDown Style="{StaticResource expNumUpDownStyle}" />

```

A [stackoverflow answer](http://stackoverflow.com/questions/17160298/wpftoolkit-autocompletebox-style-trigger-isfocused-not-firing) for the same problem with a different toolkit control suggested attaching handlers to GotFocus and LostFocus on a derived control. I tried this but couldn't get this to work.

I also tried tracing the IsFocused value in these handlers, and it appeared to remain false, regardless of focus status.

Do you know if this is a known problem, and is there any workaround?
Comments: ** Comment from web user: BoucherS **

Hi,

As soon as the NumericUpDown gets the Focus, the Focus is transferred to its WatermarkTemplate (to be able to edit right away).

Try testing IsKeyboardFocusWithin property. It will gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements
```
<Style x:Key="expNumUpDownStyle"
TargetType="xctk:DoubleUpDown">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="True">
<Setter Property="Background"
Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
```


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>