|
Hello all,
So I am writing my first application using Caliburn.Micro. I am really loving it so far but I am having a problem. I have set up my View and my ViewModel. I am using a Ria service to bring some entities in from a remote database. It appears that everything
should be working. I query the DomainContext and I get back some items however they never bind to the View. Here is some sample code of my ViewModel.
public class RssItemsViewModel: BaseViewModel<IView, IModel>
{
#region Properties/Members
protected EntityManager manager = new EntityManager();
protected LoadOperation<RssItemEntity> loadOperation;
public IEnumerable<RssItemEntity> RssItemsCollection
{
get { return manager.Context.RssItemEntities; }
}
#endregion
#region Constructors
public RssItemsViewModel()
: base()
{
View = new RssItemsView();
Model = new RssItemsModel();
//manager.Context.RssItemEntities;
if(!DesignerProperties.IsInDesignTool)
{
EntityQuery<RssItemEntity> query = manager.Context.GetRssItemEntitiesQuery();
loadOperation=manager.Context.Load(query.OrderByDescending(rss=>rss.Date));
loadOperation.Completed += new System.EventHandler(loadOperation_Completed);
}
}
#endregion
#region Methods
#endregion
#region Event Handlers
void loadOperation_Completed(object sender, System.EventArgs e)
{
Debug.WriteLine("Rss Items Load Operation complete");
//manager.Context.RssItemEntities.ToList().ForEach(rss => RssItemsCollection.Add(rss));
NotifyOfPropertyChange(()=>RssItemsCollection);
}
#endregion
}
And here is the View associated with it
<lib:BaseView x:Class="FantasyLeagueAdmin.SL.Views.RssItemsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lib="clr-namespace:JuntoSoft.Lib.Silverlight.Controls;assembly=JuntoSoft.Lib.Silverlight"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<DataTemplate x:Key="templateRssItem" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MinWidth="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Title}" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DateText}"
HorizontalAlignment="Right"/>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Description}"
TextWrapping="Wrap" />
<HyperlinkButton Grid.Row="2" Grid.Column="0" NavigateUri="{Binding Link}" >
<TextBlock Text="{Binding Link}" />
</HyperlinkButton>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Source}"
HorizontalAlignment="Right"/>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0">Rss Items Page</TextBlock>
<ListBox Grid.Row="1" x:Name="RssItemsList"
ItemsSource="{Binding RssItemsCollection}"
ItemTemplate="{StaticResource templateRssItem}"
Width="Auto" Height="Auto"
MinWidth="600" MinHeight="400"/>
</Grid>
</lib:BaseView>
Any help or comments would be most welcome.
Thank you in advance
MacKenzie
|