RikWare
...

Avalon resources

Saturday, 31 December 2005 17:56 by admin

Here's a nice overview of resources in avalon. In particular it showed me how to easily display embedded images. There's a follow-up on the pack uris as well.

http://nerddawg.blogspot.com/2005/11/resources-in-windows-presentation.html
http://nerddawg.blogspot.com/2005/12/more-on-resource-loading-in-wpf.html

Meanwhile here's a screenshot of my current Avalon effort, an implementation of the board game Carcassonne. Unfortunately you don't get the pretty fade-in/out in a static screenshot

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Avalon
Actions:   E-mail | Kick it! | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Setting FormatConvertedBitmap Source via Binding

Thursday, 29 December 2005 05:53 by admin

Avalon's FormatConvertedBitmap is a convenient way of getting a greyscale version of an image, but it appears to have some trouble with setting the source property via data binding. The following code fails complaining that the Source property has not been set on the FormatConvertedBitmap:

<Image Grid.Column="0" Grid.Row="1" Width="400" Height="200">
<Image.Source>
<FormatConvertedBitmap Source="{Binding Path=ImageSource,
Converter={StaticResource imageFormatConverter}}" DestinationFormat="Gray32" />
</Image.Source>
</Image>

I've tested the databinding on a standard image and it is fine. Similarly the code works correctly if a uri is entered instead of the binding expression.

I've no idea why this is happening, but I have managed to find a work around by using a converter to set the outer image's source instead of embedded XAML. e.g.

<Image Grid.Column="1" Grid.Row="1" Source="{Binding Path=ImageSource, 
Converter={StaticResource imageFormatConverter},
ConverterParameter=Gray32}" />

public class FormatConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
BitmapSource source = new BitmapImage(new Uri(value.ToString()));
return new FormatConvertedBitmap(source,
(PixelFormat)new PixelFormatConverter().ConvertFrom(parameter), null, 0);
}

public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}

I suppose I should fire this at the newsgroup and see if I can find more insight into what's happening.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Avalon
Actions:   E-mail | Kick it! | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Avalon, the Dispatcher Thread and Databinding

Friday, 2 December 2005 15:18 by admin

I've found an issue with the Avalon databinding. I have a library which updates itself in response to a FileSystemWatcher. The problem is that when I bind to this library it throws an exception when this update occurs because it the change doesn't happen on the Avalon dispatcher thread. I'm not sure how to get around this. I'm not directly involved in updating the UI since it's being done via databinding and the library has no knowledge of the UI so it can't redirect the update onto the dispatcher thread. Not sure where to go with this. My initial thoughts is that the databinding code should know how to move onto the dispatcher thread transparently.

System.NotSupportedException was unhandled
Message="This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread."
Source="PresentationFramework"
StackTrace:
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Avalon
Actions:   E-mail | Kick it! | del.icio.us | Permalink | Comments (10) | Comment RSSRSS comment feed

Avalon Hits RikWare

Thursday, 1 December 2005 06:29 by admin

My first forays into the world of Avalon (Windows Presentation Foundation) are going well. Avalon databinding is very nice. Speeds up UI devlopment heaps, which gives you plenty of time to waste trying to work out how to do things since there's little documentation to help.

Anyway, here's a screenshot to show you some stuff. Sorry... I haven't been wasting time putting in lots of pretty animations and gradients. The hardest thing so far was getting the treeview in there. ObservableCollection is great, but ObservableDictionary would be great too...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Avalon
Actions:   E-mail | Kick it! | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed