make your buttons attach to the border in wpf so if you close border the buttons will disapear as well

deniz koyuncu 11 Reputation points
2022-02-05T14:07:34.05+00:00

same as title smh

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,670 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sreekanth Nadendla 321 Reputation points Microsoft Employee
    2022-02-05T18:32:59.997+00:00

    Hello dnizkoyuncu, do you have a question related Microsoft Open Specifications? please provide detailed description of your issue.

    Regards,
    Sreekanth Nadendla
    Microsoft Windows Open Specifications

    0 comments No comments

  2. Hui Liu-MSFT 38,191 Reputation points Microsoft Vendor
    2022-02-08T06:17:51.08+00:00

    Here is an example of binding the visibility of a Button to a Border. (The visibility of child controls in Border is consistent with Border.)
    MainWindow.xaml:

    <Window.Resources>  
            <local:BooleanToVisibilityConverter x:Key="BoolToVisConv"/>  
        </Window.Resources>  
        <Grid>  
            <Grid.ColumnDefinitions>  
                <ColumnDefinition/>  
                <ColumnDefinition/>  
            </Grid.ColumnDefinitions>  
            <Grid.RowDefinitions>  
                <RowDefinition/>  
                <RowDefinition/>  
            </Grid.RowDefinitions>  
            <Border x:Name="border" Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1"   
                    Visibility="{Binding IsChecked, ElementName=toggleButton, Converter={StaticResource BoolToVisConv}}" >  
                <Button x:Name="btn" Content="button1" Width="200" Height="100"  />  
            </Border>  
            <ToggleButton x:Name="toggleButton" Grid.Column="1" Content="visibility" Width="200" Height="100"    />  
            <Button Width="100" Height="100" Content="button"  Visibility="{Binding IsVisible, ElementName=border, Converter={StaticResource BoolToVisConv}}"/>  
        </Grid>  
    

    MainWindow.xaml.cs:

    using System.Windows;  
    using System.Windows.Data;  
    
    namespace BorderAndButtonVisibility  
    {  
      public partial class MainWindow : Window  
      {  
        public MainWindow()  
        {  
          InitializeComponent();  
        }  
      }  
      public class BooleanToVisibilityConverter : IValueConverter  
      {  
        private object GetVisibility(object value)  
        {  
          if (!(value is bool))  
            return Visibility.Hidden;  
          bool objValue = (bool)value;  
          if (objValue)  
          {  
            return Visibility.Visible;  
          }  
          else  
          {  
            return Visibility.Hidden;  
          }  
        }  
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)  
        {  
          return GetVisibility(value);  
        }  
        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)  
        {  
          throw new System.NotImplementedException();  
        }  
      }  
    }  
    

    The result:
    172029-11.gif


    If the response is helpful, please click "Accept Answer" and upvote it.
     Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread. 

    [5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html

    0 comments No comments