Is set IsInitialLoadEnable="True" through the XAML of my CslaDataProvider, but the Factory method never seems to fire unless I call myProvider.Refresh() explicitly. Is this to be expected?
<
csla:CslaDataProvider x:Name="MyList" FactoryMethod="BeginGetMyList" IsInitialLoadEnabled="True" DataChanged="MyList_DataChanged" ObjectType="MyLibrary.MyList, MyLibrary"> <csla:CslaDataProvider.FactoryParameters> <myLibrary:MyCriteria></myLibrary:MyCriteria> </csla:CslaDataProvider.FactoryParameters> </csla:CslaDataProvider>It
fires when Data property is accessed for the first time, usually via data
binding. If you are not binding to this provider, you will need to call
refresh manually to trigger the load.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: decius
[mailto:cslanet@lhotka.net]
Sent: Tuesday, August 04, 2009 3:09 PM
To: Sergey Barskiy
Subject: [CSLA .NET] IsInitialLoadEnable="True"
Is set IsInitialLoadEnable="True" through the XAML of my
CslaDataProvider, but the Factory method never seems to fire unless I call
myProvider.Refresh() explicitly. Is this to be expected?
<csla:CslaDataProvider
x:Name="MyList"
FactoryMethod="BeginGetMyList"
IsInitialLoadEnabled="True"
DataChanged="MyList_DataChanged"
ObjectType="MyLibrary.MyList,
MyLibrary">
<csla:CslaDataProvider.FactoryParameters>
<myLibrary:MyCriteria></myLibrary:MyCriteria>
</csla:CslaDataProvider.FactoryParameters>
</csla:CslaDataProvider>
Thankyou, but yes I am binding. I am binding a combo box to this provider. I know the binding works because my call to provider.Refresh() updates the binded source item to the combobox fine without any explicit code to reference the combobox. Below is more code to show this. I am coding for Silverlight with Csla3.7
<
ComboBox x:Name="ddlMtfList" ItemsSource="{Binding Source={StaticResource MyListProvider.Data}}" Style="{StaticResource ComboBoxStyle1}" Grid.Row="1" Grid.Column="1"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=MyProperty}"></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
public
partial class Page : UserControl{
public Page(){
InitializeComponent();
}
protected void Provider_DataChanged(object sender, EventArgs e){
CslaDataProvider provider = sender as CslaDataProvider; //(CslaDataProvider)(this.Resources["BaseListProvider"]); if (provider.Error != null)System.Windows.Browser.
HtmlPage.Window.Alert(string.Format("{0}\n\n{1}", provider.Error.Message, provider.Error.ToString()));}
private void btnRefresh_Click(object sender, RoutedEventArgs e){
Csla.Silverlight.
CslaDataProvider provider = this.Resources["MyListProvider"] as Csla.Silverlight.CslaDataProvider;provider.Refresh();
}
}
I
think this is not quite correct. Should be more like
<ComboBox
x:Name="ddlMtfList" ItemsSource="{Binding Source={StaticResource MyListProvider}, Path=Data}" Style="{StaticResource ComboBoxStyle1}" Grid.Row="1" Grid.Column="1">
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: decius
[mailto:cslanet@lhotka.net]
Sent: Tuesday, August 04, 2009 4:26 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: IsInitialLoadEnable="True"
Thankyou, but yes I am binding. I am binding a combo box to this
provider. I know the binding works because my call to provider.Refresh()
updates the binded source item to the combobox fine without. Below is
more code to show this. I am coding for Silverlight with Csla3.7
<ComboBox
x:Name="ddlMtfList" ItemsSource="{Binding Source={StaticResource MyListProvider.Data}}" Style="{StaticResource ComboBoxStyle1}" Grid.Row="1" Grid.Column="1">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=MyProperty}"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
protected void
Provider_DataChanged(object sender, EventArgs e)
{
CslaDataProvider provider = sender as CslaDataProvider; //(CslaDataProvider)(this.Resources["BaseListProvider"]);
if (provider.Error != null)
System.Windows.Browser.HtmlPage.Window.Alert(string.Format("{0}\n\n{1}", provider.Error.Message, provider.Error.ToString()));
}
private void
btnRefresh_Click(object sender, RoutedEventArgs
e)
{
Csla.Silverlight.CslaDataProvider provider = this.Resources["MyListProvider"] as Csla.Silverlight.CslaDataProvider;
provider.Refresh();
}
}
Thank you, that actually seemed to do the trick. I'm still getting used to XAML binding syntax and mess it up quite often! Thanks again.
Copyright (c) Marimer LLC