Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF UserControl Focus
    primarykey
    data
    text
    <p>I have a <code>UserControl</code> subclass that contains a <code>Grid</code>, which in turn contains a couple <code>TextBlock</code>s and a <code>Border</code> (which also contains a <code>TextBlock</code>). See code below.</p> <pre><code> &lt;UserControl x:Class="ProjectNS.MyUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:my="clr-namespace:ProjectNS" mc:Ignorable="d" Height="49" Width="150" BottomResizeLocked="True" TopResizeLocked="True" MoveLocks="Vertical" Margin="0,-4" Focusable="True"&gt; &lt;my:MyUserControl.Resources&gt; &lt;Style x:Key="BorderStyle" TargetType="Border"&gt; &lt;Setter Property="Background" Value="Blue"/&gt; &lt;Setter Property="BorderBrush" Value="Blue"/&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type my:GanttBar}}, Path=IsKeyboardFocusWithin}" Value="True"&gt; &lt;Setter Property="Background" Value="{StaticResource SelectedGanttBarBackGroundBrush}"/&gt; &lt;Setter Property="BorderBrush" Value="{StaticResource SelectedGanttBarBorderBrush}"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/my:MyUserControl.Resources&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="2*" /&gt; &lt;RowDefinition Height="3*" /&gt; &lt;RowDefinition Height="2*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Label FontSize="8.5" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4,0,0,0" Foreground="Green" /&gt; &lt;Border Grid.Row="1" CornerRadius="5" BorderThickness="1.5" Style=" {StaticResource BorderStyle}" FocusVisualStyle="{StaticResource SelectedBorderStyle}" Focusable="True" &gt; &lt;Label FontSize="10" HorizontalAlignment="Center" FontWeight="Bold" VerticalAlignment="Top" Foreground="White" Margin="0,2,0,0" /&gt; &lt;/Border&gt; &lt;Label HorizontalAlignment="Right" FontSize="8.5" Grid.Row="2" VerticalAlignment="Top" Margin="0,0,4,0" Foreground="Red" /&gt; &lt;/Grid&gt; &lt;/my:MyUserControl&gt; </code></pre> <p>I'm trying to get the color of the embedded Border to change color when my <code>UserControl</code> receives focus, but I can't for the life of me figure out what actually receives focus when I click on the control. I've tried using the <code>GotFocus</code> event for every control, and nothing fires once the program is running.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload