This question is locked. New answers and comments are not allowed.
Hello,
After an almost self explanatory thread title...Hands on code...
this is my XAML
in my XAML i have tried the Binding with Path=, without it, all possible ways.
this is my ViewModel for this XAML
this is my XAML Codebehind
Thing is that i should be able to see in my textboxs the string i passed when i first created the RetailCustomer object... but it's not happening.
Something curious thou. When i set a step on my XAML code behind... right at the event when i showdialog my window, the DataContext was my RetailCustomer object... which means SOMEHOW it's connecting to the ViewModel, but it's not showing the values.
I am following TaskIt application as a model for my application... it works for him, but not for me. Where am i screwing things up here? i almost have a REPLICA of his code but i cant get the radwindow to work.
Thank you
After an almost self explanatory thread title...Hands on code...
this is my XAML
<telerik:RadWindow x:Name="winNewCustomerWindow" Header="New Customer..." WindowStartupLocation="CenterOwner" DataContext="{Binding Path=RetailCustomer, Mode=TwoWay}" > <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal" Margin="5"> <TextBlock Text="First Name:" /> <TextBox Width="100" Text="{Binding Path=FirstName, Mode=TwoWay}" /> </StackPanel> <StackPanel Orientation="Horizontal" Margin="5"> <TextBlock Text="Last Name:" /> <TextBox Width="100" Text="{Binding LastName, Mode=TwoWay}" /> </StackPanel> <StackPanel Orientation="Horizontal" Margin="5" HorizontalAlignment="Right"> <Button Content="SAVE" Command="{Binding SaveEntityCommand}" /> </StackPanel> </StackPanel> </telerik:RadWindow>this is my ViewModel for this XAML
[PartCreationPolicy(CreationPolicy.NonShared)] [Export(ViewModelTypes.MainAgentPageViewModel)] public class MainAgentPageViewModel : IFGViewModelBase { IRetailModel _model; [ImportingConstructor] public MainAgentPageViewModel(IRetailModel model) { _model = model; Messenger.Default.Register<NewEntityArgs>(this, OnNewCustomer); } #region Methods public void OnNewCustomer(NewEntityArgs entityArgs) { RetailCustomer = (RetailCustomer)entityArgs.Entity; RetailCustomer.FirstName = "Test FirstName"; RetailCustomer.LastName = "Test LastName"; NotifyNewCustomer(); } #endregion #region Properties public const string RetailCustomerPropertyName = "RetailCustomer"; private RetailCustomer _retailCustomer = null; public RetailCustomer RetailCustomer { get { return _retailCustomer; } set { if (_retailCustomer == value) { return; } _retailCustomer = value; // Update bindings, no broadcast RaisePropertyChanged(RetailCustomerPropertyName); } } #endregion #region Events public event RoutedEventHandler NewCustomer; public void NotifyNewCustomer() { if (NewCustomer != null) { NewCustomer(this, new RoutedEventArgs()); } } #endregion }this is my XAML Codebehind
public partial class MainAgentPage : UserControl { /// <summary> /// Initializes a new instance of the MainAgentPage class. /// </summary> public MainAgentPage() { InitializeComponent(); Loaded += new RoutedEventHandler(OnLoaded); if (!IFGViewModelBase.IsInDesignModeStatic) CompositionInitializer.SatisfyImports(this); } void OnLoaded(object sender, RoutedEventArgs e) { DataContext = ViewModel; ViewModel.NewCustomer += new RoutedEventHandler(OnNewCustomer); } void OnNewCustomer(object sender, RoutedEventArgs e) { winNewCustomerWindow.ShowDialog(); } [Import(ViewModelTypes.MainAgentPageViewModel)] public MainAgentPageViewModel ViewModel { get; set; } }Thing is that i should be able to see in my textboxs the string i passed when i first created the RetailCustomer object... but it's not happening.
Something curious thou. When i set a step on my XAML code behind... right at the event when i showdialog my window, the DataContext was my RetailCustomer object... which means SOMEHOW it's connecting to the ViewModel, but it's not showing the values.
I am following TaskIt application as a model for my application... it works for him, but not for me. Where am i screwing things up here? i almost have a REPLICA of his code but i cant get the radwindow to work.
Thank you