---
title: "WPF Showing / Hiding a control with triggers"  
description: "WPF Showing / Hiding a control with triggers"  
author: "marcel ethan"  
published: 2013-07-18  
updated: 2013-07-18  
canonical: https://www.mindstick.com/forum/1313/wpf-showing-hiding-a-control-with-triggers  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# WPF Showing / Hiding a control with triggers

Hi experts!

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to create xaml logic to show / hide a [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) based on the value of the AllowMiscTitle on the ViewModel. The xaml consist of two [fields](https://www.mindstick.com/forum/159126/sql-query-for-all-tables-and-fields-in-an-oracle-db) a [combobox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) of the [standard](https://www.mindstick.com/articles/23223/naming-convention-or-coding-standard) tiles ("Mr", "Mrs", ..., "Other") when "Other" is selected I want the [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) to display.

I've created the follow xaml:

<DockPanel Validation.Error="Validation_Error" HorizontalAlignment="Stretch">

<ComboBox ItemsSource="{[Binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) Path=Titles, Mode=OneTime}"

Text="{Binding Path=Title}"/>

<TextBox x:Name="TxtBxTitle" Margin="5,5" [Visibility](https://www.mindstick.com/blog/301300/how-to-improve-your-visibility-in-zero-click-search-results)="Visible">

<TextBox.Style>

<Style>

<Style.Triggers>

<DataTrigger Binding="{Binding Path=AllowMiscTitle}" Value="false">

<Setter [Property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp)="TextBox.Visibility" Value="Hidden"/>

</DataTrigger>

</Style.Triggers>

</Style>

</TextBox.Style>

</TextBox>

</DockPanel>

thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by shreesh chandra shukla

Solution!

That trigger won't work because you set Visibility explicitly in TextBox

try this..

```
<TextBox x:Name="TxtBxTitle"
Margin="5,5">               
<TextBox.Style>                   
<Style>                       
<Style.Triggers>                           
<DataTrigger Binding="{Binding Path=AllowMiscTitle}"
Value="false">                                <Setter
Property="TextBox.Visibility" Value="Hidden"/>                           
</DataTrigger>                       
</Style.Triggers>                   
</Style>               
</TextBox.Style>           
</TextBox>
```


---

Original Source: https://www.mindstick.com/forum/1313/wpf-showing-hiding-a-control-with-triggers

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
