I created a simple User Control and used it in the xaml file (mainWindow.xaml).
I named the instance VolumeMeter of the user control and then tried to use it in function in the cs file (mainWindow.cs) but the name is not recognized
The name doesn't exist in the current context
Why is that and what can I do to fix it?
xaml:
<Window x:Class="testUserControl.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:MyNameSpace="clr-namespace:testUserControl.UserControls"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Button Name="btnShow" Content="Show"></Button>
        <StackPanel Name="stkTest" Grid.Row="1" Orientation="Vertical">
            <MyNameSpace:UserControl1 Name="VolumeMeter"></MyNameSpace:UserControl1>
        </StackPanel>
    </Grid>
</Window>
cs file:
namespace testUserControl
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void btnShow_Click_1(object sender, RoutedEventArgs e)
        {
             VolumeMeter.Enable = false;//Compile error
        }
    }
}
 
     
     
     
     
    