I have some wpf windows, some classes and one viewmodel. Somehow, the value of the input field doesn't bind when I tell it to and the value in the viewmodel stays NULL.
I actually went on to use the value, but realized it has a NULL value during debugging.
In the input window:
<dx:ThemedWindow
x:Class="DXEbayManager.NewProductsMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
Title="NewProductsMenu" Height="200" Width="450">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Label Content="Product Name: " Grid.Column="0"/>
<TextBox x:Name="ProductNameBox" Text="{Binding ProductName}" Grid.Column="1"/>
</Grid>
</StackPanel>
</dx:ThemedWindow>
In my ViewModel I have:
public class NewProductsMenuVM : ViewModelBase
{
public string ProductName { get; set; }
public static NewProductsMenuVM Instance { get; } = new NewProductsMenuVM();
}
And I would like to use the value here (where it is NULL):
public partial class NewProductsMenu : ThemedWindow
{
public void saveToDB()
{
string ProductName = NewProductsMenuVM.Instance.ProductName;
}
}
I don't have the best debugging skills, but the value after the {get; set; }
was also already NULL. Why did this happen and what way is there around it?