I have a C# class library project in my solution, in which I added a User Control and pasted the following code from my WPF application.
The xaml looks all fine, but I am getting certain errors on compiling. For eg:
1) System.Windows.DataFormats' does not contain a definition for 'StringFormat'
2) System.Windows.Controls.TextBlock' does not contain a definition for 'Background' and no extension method 'Background' accepting a first argument of type 'System.Windows.Controls.TextBlock' could be found
3) System.Windows.Media.Colors' does not contain a definition for 'LightCoral'
4) System.Windows.Controls.TextBlock' does not contain a definition for 'Background' and no extension method 'Background' accepting a first argument of type 'System.Windows.Controls.TextBlock' could be found (are you missing a using directive or an assembly reference?)
I am not sure why these errors are occuring and these are related to TextBox’s background, Drag Drop, DataFormats etc. The .xaml.cs code is here as well. http://pastebin.com/CY8E8prz
You have to remove the properties referred to by the errors, because Silverlight simply doesn’t have them or they have a different name (WPF and Silverlight aren’t exactly the same, the former has more features than the latter).
A few examples:
TextBlock, you can wrap it in aBorder(adjusting positioning/sizing attributes accordingly).LightCorallooks like a color name, you’ll have to look up something similar or useColor.FromArgb()In short, copy-pasted code from WPF to Silverlight very rarely works as-is.