WPF: access to XAML objects / forms / path declared using C #

I am new to WPF and I would like to ask if it is possible to access my WPF projects using C #.

Here is a line of code from WPF:

<Path x:Name="layout1"
      Fill="Red" Stretch="Fill" Stroke="Red"
      HorizontalAlignment="Left" Margin="374.714,140.786,0,0"
      VerticalAlignment="Top" Width="116.215" Height="109.571"
      Data="M374.71429,204.14286 L387.07172,249.357 489.9328,157.92762 451.36006,140.78486 428.50213,157.92762 409.21576,173.64206 390.6437,189.35651 z"
      />

How do I access 'layout1' ( using C # ) so that I can change its visibility to β€œhidden”?

+3
source share
2 answers

Very simple:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    layout1.Visibility = System.Windows.Visibility.Hidden;
}

in any code method.

+4
source

, , x: , layout1. , ,

x:FieldModifier="public"

. , , . , , x: Name.

+1

Source: https://habr.com/ru/post/1735698/


All Articles