Setting the Main View Model content.

Anonymous 9 years ago 0
This discussion was imported from CodePlex

Rogad wrote at 2013-12-04 20:23:

I'm working with the SimpleDemo and getting stuck as I am new to C#.

I see this in the code :
        /// <summary>
        /// Gets or sets the model.
        /// </summary>
        /// <value>The model.</value>
        public Model3D Model { get; set; }
I assume this is going to load and get the current model in the scene ?

So how can I load a model from outside of the MainViewModel.cs ?

Hopefully I can explain where I am. I reduced the size of the HelixViewPort and added a slider and a text box. At this point I am just playing, but lets say I want the slider to trigger models. So when it is to the right it is one model and to the left a different model.

I have some code I came up with for the form :
namespace ExampleBrowser
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>

using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Media3D;

using HelixToolkit.Wpf;

    public partial class MainWindow : Window
        public static int foo;

        public MainWindow()
            this.DataContext = new MainViewModel();

        public void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)

            ObjReader CurrentHelixObjReaderb = new ObjReader();
            Model3DGroup MyCube = CurrentHelixObjReaderb.Read("C:/Users/Roger/Desktop/cube/cube-long.obj");

            // And now what ?!


Here's an image of my form that may help :

I'm just stuck on loading the model into the viewer. I can do it in the MainViewModel.cs quite easily
ObjReader CurrentHelixObjReaderb = new ObjReader();
            Model3DGroup MyEnd = CurrentHelixObjReaderb.Read("C:/Users/Roger/Desktop/cube/cube-long.obj");

            this.Model = MyEnd;
But due to C# being new to me I don't know how to do it elsewhere, like make it global or something.

Many thanks for any help :)

Rogad wrote at 2013-12-05 17:10:

Please delete this thread if you see fit. I realise I was leading myself up a blind alley.