I'll try to focus on the CSLA-related aspects to this question. Some of what you are asking is just WPF development skills and techniques.
You can use a CslaDataProvider on both the main form and dialog. In the main form you'll probably have it actually get the data by calling a factory method.
<csla:CslaDataProvider x:Key="data"
FactoryMethod="GetList"
ObjectType="{x:Type this:DataItemList}"
ManageObjectLifetime="True"/>
In the dialog form you will not allow it to call a factory method, and instead will somehow (probably in code-behind) set the ObjectInstance property.
<csla:CslaDataProvider x:Key="data"
ObjectType="{x:Type this:DataItem}"
ManageObjectLifetime="True"
IsInitialLoadEnabled="False"/>
How you do your code-behind can vary a lot, depending on how you decide to structure your application and its code. But the basic concept is pretty straightforward - this code is in the main form and sets up and displays the dialog:
private void ListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var selected = DataList.SelectedItem as DataItem;
if (selected != null)
{
var dlg = new Window2();
var dp = dlg.Resources["data"] as Csla.Wpf.CslaDataProvider;
dp.ObjectInstance = selected;
dlg.ShowDialog();
}
}
The key is that I'm setting the ObjectInstance property of the data provider in the dialog. The last bit is the Save button event handler in the dialog:
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
var dp = Resources["data"] as Csla.Wpf.CslaDataProvider;
var obj = (DataItem)dp.Data;
obj.ApplyEdit();
this.Close();
}
Because I told the data provider in the dialog to manage the object's lifetime, I need OK/Cancel buttons that call ApplyEdit() and CancelEdit() before closing the form.
Copyright (c) Marimer LLC