Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Null reference exception when calling one class from another

$
0
0

I have 2 classes .First class contains all the ui elements and the second one has a slider control to increse the lenght and the width of the first ui ( a canvas )

public partial class MainWindow : Window
    {

        
        public MainWindow()
        {
            InitializeComponent();

           
            Window2 win = new Window2(this);   // Name of the animation control window
            win.Show();
           
            
        }
        

its xaml is

<Canvas Background="#FF6F6F6F" Name="grid1" ></Canvas>

The second class is

public partial class Window2 : Window { double zoomf; MainWindow m1; public Window2( MainWindow main) { InitializeComponent(); zoomf = 1.0; m1 = main; timer_start(); } private void Slider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e) { double val= sl1.Value; zoomf = val; m1.grid1.Height = 700 * zoomf

m1.grid1.Width = 816 *zoomf;

// Throws the null referece exception at this line

} }

Can someone point out the error?


arka Bhattacharya


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>