WCF HttpTransport: streamed vs buffered TransferMode

As you use ‘GZipMessageEncodingBindingElement’, I assume you are using the MS GZIP sample. Have a look at DecompressBuffer() in GZipMessageEncoderFactory.cs and you will understand what’s going on in buffered mode. For the sake of example, let’s say you have a message of uncompressed size 50M, compressed size 25M. DecompressBuffer will receive an ‘ArraySegment buffer’ param … Read more

Binding [VisualStateManager] view state to a MVVM viewmodel?

Actually you can. The trick is to make an Attached property and add a property changed callback that actually calls GoToState: public class StateHelper { public static readonly DependencyProperty StateProperty = DependencyProperty.RegisterAttached( “State”, typeof( String ), typeof( StateHelper ), new UIPropertyMetadata( null, StateChanged ) ); internal static void StateChanged( DependencyObject target, DependencyPropertyChangedEventArgs args ) { … Read more

How to Avoid Firing ObservableCollection.CollectionChanged Multiple Times When Replacing All Elements Or Adding a Collection of Elements

ColinE is right with all his informations. I only want to add my subclass of ObservableCollection that I use for this specific case. public class SmartCollection<T> : ObservableCollection<T> { public SmartCollection() : base() { } public SmartCollection(IEnumerable<T> collection) : base(collection) { } public SmartCollection(List<T> list) : base(list) { } public void AddRange(IEnumerable<T> range) { foreach … Read more

Validation does not work when I use Validator.TryValidateObject

I found the answer here: http://forums.silverlight.net/forums/p/149264/377212.aspx MVC recognizes the MetaDataType attribute, but other projects do not. Before validating, you need to manually register the metadata class: TypeDescriptor.AddProviderTransparent( new AssociatedMetadataTypeTypeDescriptionProvider(typeof(Customer), typeof(CustomerMetadata)), typeof(Customer)); var isValid = Validator.TryValidateObject(new Customer(), context, results, true);

Dynamically setting the Header text of a Silverlight DataGrid Column

You can’t Bind to Header because it’s not a FrameworkElement. You can make the text dynamic by modifying the Header Template like this: xmlns:data=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data” xmlns:dataprimitives=”clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data” <data:DataGridTemplateColumn> <data:DataGridTemplateColumn.HeaderStyle> <Style TargetType=”dataprimitives:DataGridColumnHeader”> <Setter Property=”Template”> <Setter.Value> <ControlTemplate> <TextBlock Text=”{Binding MeetingName, Source={StaticResource LocStrings}}” /> </ControlTemplate> </Setter.Value> </Setter> </Style> </data:DataGridTemplateColumn.HeaderStyle> </data:DataGridTemplateColumn>

Creating a Silverlight DataTemplate in code

Although you cannot programatically create it, you can load it from a XAML string in code like this: public static DataTemplate Create(Type type) { return (DataTemplate) XamlReader.Load( @”<DataTemplate xmlns=””http://schemas.microsoft.com/client/2007″”> <” + type.Name + @”/> </DataTemplate>” ); } The snippet above creates a data template containing a single control, which may be a user control with … Read more

How do you force Firefox to not cache or re-download a Silverlight XAP file?

The query string works perfectly, but I wouldn’t use DateTime.Now, because it forces the user to re-download the app every time. Instead, we use the following: protected void Page_Load(object sender, EventArgs e) { var versionNumber = Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.myApp.Source += “?” + versionNumber; } This way all you have to do is increment the version number … Read more

MVVM: Binding to Model while keeping Model in sync with a server version

In the past I ‘ve written an application that supports “live” editing of data objects from multiple locations: many instances of the app can edit the same object at the same time, and when someone pushes changes to the server everyone else gets notified and (in the simplest scenario) sees those changes immediately. Here’s a … Read more