Browse by Tags

All Tags » .NET 3.5 (RSS)

Silverlight at Windows Phone 7

Microsoft announced today, that new Windows Phone 7 Series will support Silverlight as one of 2 development frameworks. Second development framework will be XNA (will blog about it later). So, what’s new for Silverlight developers there? First, we have familiar tools: Windows Phone applications with Silverlight will be developed either with Visual Studio 2010, either with new “express” version called Visual Studio 2010 Express for Windows Phone. This “express” version will enable development with...

Silverlight Tip: Enumerating embedded resources

Today I’ve got a “Call for Help” from one of Silverlight MVPs – Bill Reiss . The mail said: “I would like to enumerate all items that were marked as Content or Resource in the main XAP file. If I can’t do both I’d settle for one. Any sample code for this would be greatly appreciated. Bill”   I decided to help with embedded resources, because I did something like this in WPF. I’ve created sample application, which will display a list of resources in list box – from here it is very easy to use...

Silverlight Quick Tip: How to get localized resources from RESX file in code behind

It looks like I’m using too much resources and localizing too much applications lately :) This time I’ll show how to use localized resources from the RESX files. Here I already explained how to create the RESX files for Silverlight (by the way the article is relevant also for Visual Studio 2010 Beta 2 & Silverlight 3), and how to use those resources from XAML. In some cases, though, it is needed to use those resources from code behind. In my scenario I had to create value converter, which converts...

Silverlight Quick Tip: ChildWindow Title Customization

Today I discovered nice feature of ChildWindow control in Silverlight 3. I was at client’s location and been asked about the ChildWindow title customization with an icon. I had to admit, that I never tried to put something different than text and immediately looked at the type of Title property. For my surprise I found that the property is an “object”, and assumed that it could behave as a ContentPresenter/ContentControl. After 5 minutes I had the client’s request solved: My code is very simple:...

WPF Quick Tip: How to get WPF Window client area size

This time my quick tip will be not about the Silverlight, but about WPF. When you have WPF window, the runtime size of it could be discovered by ActualWidth/ActualHeight properties. In most cases this is enough. But what about the case, when you need to perform some mathematical calculations based on the real size of client area? What is this client area? Well, the second question is really easy one – the client area is the area available to user defined UI (controls, panes, etc.): At the screenshot...

Silverlight Quick Tip: Dynamically Updating Class Fields/Properties

In previous post ( here ) I blogged about displaying values of class/control in runtime and displaying them in Visual Studio - like property window. Today I’ll show how to push them back to the class instance. In previous post I’ve stored values in “ObservableCollection<FieldsPropertiesData>” for easy databinding and connected this ListBox control. In order to get user input I’ve created TwoWay databinding in DataTemplate – here is updated data template: < Style TargetType ="local:FiledPropertyData">...

Silverlight Quick Tip: Dynamically Displaying Class Fields/Properties

In one of my projects I had to create something like Visual Studio property window, for data set of different controls/data classes. Those controls/classes are still under development and I needed the way to display/change values of those properties dynamically without even knowing what is inside. For the simple case, let’s assume the following class which holds the data: public class SampleData { public SampleData() { BooleanProperty = false ; } public string StringProperty { get ; set ; } public...

Silverlight Quick Tip: Resources in RESX files – Image Resources for Localization

This post was actually born in the middle of previous post :) I had to find the way to use images as a RESX resources – this actually was second question of the person who asked me about forcing the rebinding . Before starting, some theory about RESX usage in Silverlight. Silverlight support usage of RESX files and localization via “SupportedCultures” attribute in CSPROJ file. The attribute itself even exists in project created with Silverlight 3 Tools, but for some reason there is no interface to...

Silverlight Quick Tip: How to force re-binding

Today I’ll show how to do “dirty trick” to force re-binding and as a result UI value updating. First of all – the reasonable question – “Why force rebinding? Why not use INotifyPropertyChanged mechanism?” This was my questions also, but the person who asked the question had his reasons: he is using resources (Resx) to localize the application and bind the UI to those resources. Also UI gives user an ability to change the language (and code behind does it by changing CurrentThread.CurrentUICulture...

Silverlight 3 Quick Tip: Analytics

Silverlight 3 has new feature which should help us to understand how good our application performs. This feature is Analytics class. It Has 2 read-only properties AverageProcessLoad – average CPU used by this process across all the cores AverageProcessorLoad – average CPU usage across all cores In addition it has GpuCollection collection with objects of GpuInformation type. Each one of GpuInformation object provides information about: DeviceId – device ID of the GPU VendorId – vendor ID of the GPU...

Silverlight 3 Quick Tip: Animation Easing and VSM

New version of VSM in Silverlight 3 got new interesting addition – ability to use Easing Function for visual state transition animation. To use it, set the property “GeneratedEasingFunction” to desired VisuaStateTransition element and provide it with class instance with implements IEasingFunction. From XAML: < vsm : VisualTransition GeneratedDuration ="00:00:10"                                ...

Silverlight 3 Quick Tip: Native Mouse Wheel Support

Silverlight 3 supports the mouse wheel events natively. To use this handy feature just subscribe to “MouseWheel” of UIElement. The reported values will be like follows: Positive for forward scroll Negative for backward scroll   Enjoy, Alex

Silverlight 3 Quick Tip: Out Of Browser Settings

In MIX 09 Beta build of Silverlight 3, when we wanted to enable out-of-browser experience, we had to edit manually AppManifest.xml. Now for Silverlight 3 projects in Visual Studio 2008 we got the out of browser settings helper dialog box The dialog will be saved in “OutOfBrowserSettings.xml” and this file contents will be merged on compile time to the AppManifest.xml. For hardcore programmers, who wants to write every single piece of the application without wizards/helpers – you still could use AppManifest...

Silverlight 3 Quick Tip: Multitouch support on Windows 7

Silverlight 3 supports Multitouch on Windows 7. Touch class –provides input information and resides in System.Windows.Input namespace “FrameReported” event - fired when touch action occurs. Event arguments provide the following info: Timestamp: identify the touch event by time GetTouchPoints function (over specific UI Element) GetPrimaryTouchPoint function (over specific UIElement) SuspendMousePromotionUntilTouchUp function GetTouchPoints returns TouchPointCollection In TouchPointCollection first...

Silverlight 3 Quick Tip: Browser Zoom Support

New version of Silverlight 3 supports zoom events from the hosting browser environment. “Zoomed” event is the new event in Content static object, and the current browser’s zoom factor in “ZoomFactor” property of the Content object:   App.Current.Host.Content.Zoomed += (s, e) => {     //Browser’s Zoom in:App.Current.Host.Content.ZoomFactor; };   Enjoy, Alex
More Posts Next page »