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

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>

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

Display GIF in a WP7 application with Silverlight

In fact, it’s working, but it lacks some documentation. After some troubles, here’s how to use it : reference ImageTools reference ImageTools.Controls reference ImageTools.IO.Gif Add namespace in xaml : xmlns:imagetools=”clr-namespace:ImageTools.Controls;assembly=ImageTools.Controls” And resources : <phone:PhoneApplicationPage.Resources> <imagetools:ImageConverter x:Key=”ImageConverter” /> </phone:PhoneApplicationPage.Resources> Then use the control with the converter : <imagetools:AnimatedImage Source=”{Binding ImageSource, Converter={StaticResource ImageConverter}}” /> Your ImageSource should … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)