WPF: Access XAML objects/shapes/path declared using C#
c#, wpf
Solution
Very simple:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
layout1.Visibility = System.Windows.Visibility.Hidden;
}
in any code-behind method.
Problem
I'm a newbie in WPF and I would like to ask if it's possible to access my WPF ojects 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 would I access 'layout1' (using C#) in such a way that I could change its visibility into 'hidden'?