Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:22:00+00:00 2026-05-26T20:22:00+00:00

I have two controls in this example but in the real application i have

  • 0

I have two controls in this example but in the real application i have many more whick depending of the value of the property Content of a Label in Grid one (for example), some other Labels, TextBoxes, TextBlocks and Buttons will be Visible or Collapsed in Grid two (for example).

But to simplify my problem i will have a simplified example…

<Grid Name="gridOne">
    <Label Content="{Binding Collection.Name}" Name="lblCaption"/>
</Grid>

<Grid Name="gridTwo">
    <Label Content="My Label" Visibility="Collapsed">
        <Label.Style>
            <Style TargetType="Label">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ElementName=lblCaption, Path=Content}" Value="Employers">
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Label.Style>
    </Label>
    <TextBox Text="{Binding EmployerName}" Visibility="Collapsed">
        <TextBox.Style>
            <Style TargetType="TextBox">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ElementName=lblCaption, Path=Content}" Value="Employers">
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBox.Style>
    </TextBox>
</Grid>

I know that this won’t work too if i set the property Visibility as Collapsed for default in control but i have many collections and i don’t think that having one DataTrigger for each Collection is good way to achieve it. Anyway one problem comes when binding controls in different grids and other in handling the property Visibility in a good way.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:22:00+00:00Added an answer on May 26, 2026 at 8:22 pm

    Local value takes precedence over style triggers. Move the visibility intialization inside the style as:

    <Label Content="My Label">
      <Label.Style>                    
        <Style TargetType="Label">
          <Setter Property="Visibility" Value="Collapsed"/>
          <Style.Triggers>
            <DataTrigger Binding="{Binding ElementName=lblCaption, Path=Content}" Value="Employers">
              <Setter Property="Visibility" Value="Visible"/>
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </Label.Style>
    </Label>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have
I have two updatepanels inside an accordion control, laid out like this: <accordion> <first
I have two controls on a page, one is a search entry and submission
In Winforms you can have two controls tied to the same datasource in a
I am using standard windows forms controls under C#. I have two controls which
I have two custom controls that are analogous to a node and the control
I have two TDBLookupComboBox controls that I'd like to connect to the same dataset,
I've got a form where I have two radio buttons and two interchangeable controls
I have two different grid controls on the same form. They share the same
I have a C#/ASP.NET .aspx page that declares two controls that each represents the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.