-
- [email protected]
- Posts: 3
- Joined:
need d3d11 sample with MVVM and code behind
Dear support team,
The d3d11 sample project is working.
But, I need more sample in using code behind and mvvm binding in this project to learn how to integrate and use them.
Please help.
Thank you.
Chaiwarat
The d3d11 sample project is working.
But, I need more sample in using code behind and mvvm binding in this project to learn how to integrate and use them.
Please help.
Thank you.
Chaiwarat
Re: need d3d11 sample with MVVM and code behind
We are working to provide more samples directly in the C++ SDK. Just ready for opening the solution and compiling.
But for now, you can find code for MVVM in the Data Binding and Commands tutorials.
But for now, you can find code for MVVM in the Data Binding and Commands tutorials.
-
- [email protected]
- Posts: 3
- Joined:
Re: need d3d11 sample with MVVM and code behind
Dear support,
I was talking about the d3d11 sample project bundled with the Noesis package.
It was written in c# and run without Unity 3D.
In the code, it just load the style xaml and the layout xaml. So, I wonder how to integrate the code behind and view model in to this kind of environment.
{
var theme = (Noesis.ResourceDictionary)Noesis.GUI.LoadXaml("NoesisStyle.xaml");
Noesis.GUI.SetTheme(theme);
}
// Data loading
{
var content = (Noesis.Grid)Noesis.GUI.LoadXaml("TextBox.xaml");
view = Noesis.GUI.CreateView(content);
var immediateContext = dxWrapper.Device.ImmediateContext;
renderer = view.Renderer;
renderer.InitD3D11(immediateContext.NativePointer, new Noesis.VGOptions());
}
Thank you.
I was talking about the d3d11 sample project bundled with the Noesis package.
It was written in c# and run without Unity 3D.
In the code, it just load the style xaml and the layout xaml. So, I wonder how to integrate the code behind and view model in to this kind of environment.
{
var theme = (Noesis.ResourceDictionary)Noesis.GUI.LoadXaml("NoesisStyle.xaml");
Noesis.GUI.SetTheme(theme);
}
// Data loading
{
var content = (Noesis.Grid)Noesis.GUI.LoadXaml("TextBox.xaml");
view = Noesis.GUI.CreateView(content);
var immediateContext = dxWrapper.Device.ImmediateContext;
renderer = view.Renderer;
renderer.InitD3D11(immediateContext.NativePointer, new Noesis.VGOptions());
}
Thank you.
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: need d3d11 sample with MVVM and code behind
Hi,
You can attach any view model to the loaded content. For example, imagine the TextBox.xaml sample has a binding like this:
Then you can define a class exposing that property:
And attach it to the data context of the root element:
This will show the text "This is a test" in the TextBox when you launch the sample.
You can attach any view model to the loaded content. For example, imagine the TextBox.xaml sample has a binding like this:
Code: Select all
<TextBox Text="{Binding SampleText}" .../>Code: Select all
public class SampleViewModel
{
public string SampleText { get; set; }
}Code: Select all
// Data loading
{
var content = (Noesis.Grid)Noesis.GUI.LoadXaml("TextBox.xaml");
content.DataContext = new SampleViewModel { SampleText = "This is a test" };
view = Noesis.GUI.CreateView(content);
//...
}-
- [email protected]
- Posts: 3
- Joined:
Re: need d3d11 sample with MVVM and code behind
Dear support,
That's clear for the view model.
The remaining question is the code behind.
For example, if I have TextBox.xaml.cs and I have a constructor doing some initialization.
Will it work automatically when load with the command below?
var content = (Noesis.Grid)Noesis.GUI.LoadXaml("TextBox.xaml");
The d3d11 sample project does not include TextBox.xaml in the csproj. The xaml file is just an external file.
If I have a .xaml.cs file, I need to include both .xaml and .xaml.cs into the project to compile.
So, should I use this LoadXaml command or other method to handle this environment.
Thank you.
That's clear for the view model.
The remaining question is the code behind.
For example, if I have TextBox.xaml.cs and I have a constructor doing some initialization.
Will it work automatically when load with the command below?
var content = (Noesis.Grid)Noesis.GUI.LoadXaml("TextBox.xaml");
The d3d11 sample project does not include TextBox.xaml in the csproj. The xaml file is just an external file.
If I have a .xaml.cs file, I need to include both .xaml and .xaml.cs into the project to compile.
So, should I use this LoadXaml command or other method to handle this environment.
Thank you.
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: need d3d11 sample with MVVM and code behind
The code behind class must specify the associated xaml that will be loaded when root class is instantiated.
For example, if I have the following xaml:
The code behind will look like this:
This user control can now be loaded directly calling Noesis.GUI.LoadXaml("TextBox.xaml"), or included in another xaml by referencing the root class:
Either way an instance of the TextBoxSample code-behind class will be created.
For example, if I have the following xaml:
Code: Select all
<UserControl x:Class="Samples.TextBoxSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
...
</UserControl>Code: Select all
namespace Samples
{
public class TextBoxSample : Noesis.UserControl
{
public TextBoxSample()
{
InitializeComponent();
}
private void InitializeComponent()
{
Noesis.GUI.LoadComponent("TextBox.xaml");
}
...
}
}Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Samples">
<local:TextBoxSample .../>
</Grid>Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests