I'd like to have a simple dialog box with text field. For now I have:
ViewModel:
public class MyViewModel
{
public string AA { get; set; }
}
View:
public partial class MyView : Window
{
public MyView(MyViewModel context)
{
InitializeComponent();
this.DataContext = context;
}
public string BB {get; set; }
}
<Window
...>
<Grid>
<Label>name:</Label>
<TextBox Width="110">
<TextBox.Text>
<Binding Path="AA"/>
</TextBox.Text>
</TextBox>
...
</Grid >
</Window>
In order to open it and get the value I call:
MyViewModel model = new MyViewModel();
MyView dialog = new MyView(model);
dialog.ShowDialog();
Now I'm able to take the provided TextBox value from the MyViewModel AA property.
Is it possible to store the provided value in the MyView BB property (and so remove the MyViewModel)? I tried to change the xaml configuration but no mater what I put there the BB property is always null.
The only reason I ask is that my dialog will do nothing more than collect this one single value and I'd like to keep it as thin as possible.