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

  • SEARCH
  • Home
  • 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 7895769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:43:25+00:00 2026-06-03T07:43:25+00:00

In WPF, MVVC applicaiton I have quite normal listbox: <ListBox ItemsSource={Binding Friends}> </ListBox> Then

  • 0

In WPF, MVVC applicaiton I have quite normal listbox:

<ListBox ItemsSource="{Binding Friends}">
</ListBox>

Then each item of list uses following datatemplate:

<DataTemplate DataType="{x:Type model:Friend}">
    <Border BorderThickness="1" BorderBrush="Gray" Padding="3" Name="border" Margin="3">
        <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal">
            <TextBlock Name="DescriptionDTDataType" Text="{Binding Path=ConnectedUserID}" />
            <TextBlock Name="StatusTitle" Margin="8,0,4,0">Status:</TextBlock>
            <TextBlock Name="Status" Text="{Binding Path=Approved}" />
            <Button Content="Approve" Command="{x:Static inf:Commands.ApproveUserConnection}" CommandParameter="{Binding}"></Button>
            <Button Content="Disapprove" Command="{x:Static inf:Commands.DisapproveUserConnection}" CommandParameter="{Binding}"></Button>
        </StackPanel>
    </Border>
</DataTemplate>

The question is… I want to hide one of the buttons on the basic of Friend.Approved property. For example if Friend.Approved has value “approved” I want to hide button Approved and show only button Dissaprove. On the other hand if Friend.Approved has value “disapproved” then I want opposite. How to achieve this?

Thank you.

  • 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-06-03T07:43:26+00:00Added an answer on June 3, 2026 at 7:43 am

    Beside creating a IValueConverter there is a pure XAML solution using DataTriggers

    Just add this to your DataTemplate:

    <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding Approved}" Value="approved" >
            <Setter TargetName="Approve" Property="Visibility" Value="Collapsed"/>
        </DataTrigger>
        <DataTrigger Binding="{Binding Approved}" Value="disapproved" >
            <Setter TargetName="Disapprove" Property="Visibility" Value="Collapsed"/>
        </DataTrigger>
    </DataTemplate.Triggers>
    

    And name your buttons:

    <Button Name="Approve" Content="Approve" ...></Button>
    <Button Name="Disapprove" Content="Disapprove" ...></Button>
    

    However if you want to reuse this hiding logic in multiple places in multiple DataTemplates its better to write the Approved text to Visibility converter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

WPF and Silverlight have a data binding model whereby I can provide a Binding
WPF, C#, I have a datagrid with several columns, many rows. I want each
WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them
WPF launches certain method which calls external exe and waits , and then accesses
WPF applications are, at its core, managed applications? Right? So, I have to choose
WPF Experts - I am trying to add buttons below my custom listbox and
Wpf binding is funny for those who know it well and it is nightmare
WPF's DataGrid requires a double click to enter cell editing mode, and then the
WPF, Shapes I have a custom Shape , and try to implement MouseClick and
WPF has PasswordBox which receives password input into a SecureString, but I have a

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.