See how a Synergy/DE customer changed their core Unix-based application to a multi-tier application with unlimited possibilities
Come to the Synergy DevPartner Conference and learn how a company took their Unix-based Synergy application from this:
to this:
Customer detail, an advance draft listing, and a report are all loaded at the same time. Users can simply click on the tabs and switch between them.
Synergex Professional Services Group recently helped leading agribusiness software provider AgTrax de-couple their business logic from their user interface. So now they are able to deploy with either a green-screen front end or a graphical user interface and use the same business logic in either case.
At the Synergy DevPartner Conference, you will see the steps involved in developing this application, and you’ll see how the application was successfully reengineered to use Synergy/DE xfServerPlus.
Get more information about the conference at http://conference.synergex.com.
**Conference attendees: Make sure to reserve your hotel rooms as soon as possible to ensure a room in the conference block at the discounted rate!**
I support incremental loading
Windows 8 introduces an easier way to support infinite scrolling
By Jeff Greene, .NET Developer
In most UI frameworks, if you want to support infinite scrolling, you have to do something like hook scroll bar events and then load more items when the scroll bar gets to a certain position. But with XAML for Windows 8 apps there is an easier way: ISupportIncrementalLoading.
One of the major design philosophies that Microsoft has been pushing for Windows 8 apps is that everything should be highly responsive, but nothing makes software unresponsive like trying to add 10K items to a list that the user might not even scroll. To make this problem easier to solve, Microsoft added the ISupportIncrementalLoading interface. To use it, all you have to do is implement ISupportIncrementalLoading on a class that inherits from ObservableCollection. Then any virtualizable XAML container that has this bound as its DataContext will have the ability to do incremental loading. While most Microsoft-provided controls support virtualization, the following is an example of a UI control that is virtualized because it is bound to a ListView. Note that this and the other examples in this article are from a Visual Studio solution that you can download at http://synergex.com/downloads/Synereddit.zip.
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<ListView ItemsSource="{Binding Links}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Title}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
Now that you know what this looks like on the UI side, we can talk about how to implement it on the code side. Our example pulls links using a web service from the popular link aggregation site reddit.com. I’ll gloss over the specifics of talking to reddit.com, but you can download the solution mentioned above to see this.
ISupportIncrementalLoading contains two methods: HasMoreItems and LoadMoreItemsAsync. HasMoreItems, as its name suggests, is what the container calls to determine if there is more data to load. LoadMoreItemsAsync is called with a desired number of elements to load. You can load as many as you want, but the number passed to LoadMoreItemsAsync is the framework’s suggestion for optimal efficiency.
LoadMoreItemsAsync returns an IAsyncOperation, so it’s not quite compatible with Task. (See “Asynchronous programming: What you’ve been AWAITing for” from the April 12 edition of Synergy-e-News for information on Task.) But there is a helper that bridges the gap for us, namely ToAsyncOperation() on Task. This is usually implemented in this way: a private method that returns Task is called from the public implementation, with ToAsyncOperation() being called on the resultant Task object. You can see this in the following implementation of ISupportIncrementalLoading, which is from a class (RedditLinksCollection) that inherits from ObservableCollection:
private initialLoad_, boolean
private after_, @String
public property HasMoreItems, boolean
method get
proc
;;If not loaded or there is more data, then
;;it’s a good idea to call LoadMoreItemsAsync
mreturn !initialLoad_ || !String.IsNullOrWhiteSpace(after_)
endmethod
endproperty
private async method LoadMoreItemsAsyncImpl, @Task<LoadMoreItemsResult>
count, uint
endparams
proc
data result = new LoadMoreItemsResult()
data gottenJson, @string, GetTheJson()
result.Count = AddLinksFromJson(gottenJson)
mreturn result
endmethod
public method LoadMoreItemsAsync, @IAsyncOperation<LoadMoreItemsResult>
count, uint
endparams
proc
mreturn LoadMoreItemsAsyncImpl(count).AsAsyncOperation()
endmethod
Now we’re going to glue everything together in the simplest possible way. You should really use the Model-View-ViewModel (MVVM) design pattern for this sort of thing, but our example is just a single page. So when the page gets constructed, we simply set the DataContext to be a new instance of our RedditLinksCollection:
namespace Synereddit
public sealed partial class MainPage extends Page
public method MainPage
endparams
proc
this.InitializeComponent()
Links = new RedditLinksCollection()
endmethod
public property Links, @RedditLinksCollection
method get
endmethod
method set
endmethod
endproperty
endclass
endnamespace
As with all things, there are some caveats. Virtualizable UI is very nice and performs well in most cases, but if the items in your list contain expensive-to-create UI controls, remember that the UI controls are created and destroyed as they come into view. You have a lot of headroom on a modern desktop system, but this can be problematic on ARM devices and low-powered x86 devices. Keep your target device in mind.
So here’s a quick recap of what we’ve talked about here. ISupportIncrementalLoading is the Windows 8 way to do infinitely scrolling lists. It loads more data as the user scrolls down the page, and it works with any virtualizing container (derived from VirtualizingStackPanel). But don’t put expensive-to-create UI controls in one.
Synergy/DE 10.1 offers support for Windows 8. For more information, visit our web site. Download the Visual Studio solution mentioned in this article at http://synergex.com/downloads/Synereddit.zip.