Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF action on LostFocus textbox
    primarykey
    data
    text
    <p>I'm working on a WPF application and i have a little problem.</p> <p>I have 1 ToggleButton and 1 TextBox. When i click on the ToggleButton, the TextBox apears and gets focus. This is good. But now i want that when i click on another textbox or just somewhere else, that the textbox loses his focus and disapears. I tried this with Differnet triggers and setters, but can't get it to work.</p> <p>My code now:</p> <pre><code> &lt;ToggleButton x:Name="SearchButton" Width="100" Height="100" BorderThickness="0" Margin="580,0,0,0" Template="{DynamicResource ButtonBaseControlTemplate1}" Panel.ZIndex="1"&gt; &lt;ToggleButton.Style&gt; &lt;Style TargetType="ToggleButton"&gt; &lt;Style.Triggers&gt; &lt;MultiDataTrigger&gt; &lt;MultiDataTrigger.Conditions&gt; &lt;Condition Binding="{Binding IsChecked, ElementName=SearchButton}" Value="True" /&gt; &lt;Condition Binding="{Binding Visibility, ElementName=SearchBox}" Value="Visible"/&gt; &lt;/MultiDataTrigger.Conditions&gt; &lt;Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=SearchBox}" /&gt; &lt;/MultiDataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ToggleButton.Style&gt; &lt;/ToggleButton&gt;&lt;TextBox x:Name="SearchBox" Margin="100,33,0,34" Visibility="{Binding IsChecked, ElementName=SearchButton, Converter={StaticResource BoolVisibilityConverter}}" Opacity="0" FontSize="24" FontFamily="Arial" Background="{x:Null}" Foreground="#FF7F7F7F" BorderThickness="0"&gt; &lt;TextBox.Style&gt; &lt;Style TargetType="TextBox"&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="TextBox.IsFocused" Value="False"&gt; &lt;Setter Property="ToggleButton.IsChecked" Value="False" TargetName="SearchButton" /&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/TextBox.Style&gt; &lt;/TextBox&gt; </code></pre>
    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.
 

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