background preloader

WPF

Facebook Twitter

C# - Remove Control from Window in WPF. 9: Communicating Between Loosely Coupled Components Using the Prism Library 5.0 for WPF. The EventAggregator service is primarily a container for events that allow decoupling of publishers and subscribers so they can evolve independently.

9: Communicating Between Loosely Coupled Components Using the Prism Library 5.0 for WPF

This decoupling is useful in modularized applications because new modules can be added that respond to events defined by the shell or, more likely, other modules. In the Composite Application Library, EventAggregator allows subscribers or publishers to locate a specific EventBase. The event aggregator also allows for multiple publishers and multiple subscribers, as shown in Figure 1. Figure 1 Event Aggregator The EventAggregator class is offered as a service in the container and can be retrieved through the IEventAggregator interface.

The EventAggregator will construct the event on its first access if it has not already been constructed. The real work of connecting publishers and subscribers is done by the CompositeWpfEvent class. The CompositeWpfEvent is intended to be the base class for an application's or module's specific events. Simple WPF Localization. Introduction After searching the Internet for a while on how to localize a WPF application, I found two very nice solutions which can be found here and here.

Simple WPF Localization

However, both solutions looked too complicated to me, and I decided to implement a solution that will just do what I need with simplicity and effectiveness. My solution by far does not have the features of the above solutions, but it still does its job perfectly: to localize the text in my project. Background The basic goals are: WPF Localization - On-the-fly Language Selection - Essential XAML. Download code ver 1.3 from here. Many of my customers asked me: How WPF supports localization and globalization? Is there any built-in mechanism for choosing a language on-the-fly, at runtime and without closing any window? How do I translate formatted text with parameters? Well…, you know the story,… aren’t you!? As you can see, there is more than one solution. Building a multilingual MVVM app. A Guided Tour of WPF – Part 4 (Data templates and triggers) Table of Contents Part 1 (XAML): Learn about XAML and how it is used in WPF applications.

A Guided Tour of WPF – Part 4 (Data templates and triggers)

Part 2 (Layout): Learn about layout panels and how they are used to construct user interfaces. Listening to DependencyProperty changes in Silverlight. The dependency property system is a pretty nice concept.

Listening to DependencyProperty changes in Silverlight

Receiving notifications for dependency property changes on an existing object is a very common scenario in order to update my view model or the UI. This is quite easy in WPF: // get the property descriptor DependencyPropertyDescriptor prop = DependencyPropertyDescriptor.FromProperty(TextBox.TextProperty, myTextBox.GetType()); // add change handler prop.AddValueChanged(myTextBox, (sender, args) => { }); Unfortunately Silverlight has a limited set of meta-data functionality around the dependency property system, because the DependencyPropertyDescriptor does exist in Silverlight. Localization using a MarkupExtension. The Idea A simple and effective way to localize application resources is to write a custom MarkupExtension that provides a localized value.

Localization using a MarkupExtension

The extension takes a parameter in the constructor that is the unique resource key. When the DepdendencyProperty asks for the value, the markup extension looks up the value from a generic resource provider. This gives you the flexibility to reuse the resource management and translation process that is already established within your company. Localizing WPF Applications using Locbaml. Download source - 1027 Kb Table of Contents IntroductionBackgroundWhat You Will Need To Follow This Tutorial (Software Prerequisites)Approach #1: Targeted Localization Without Using LocBaml.exeCreating The WPF ApplicationAdding a Button to the Window Adding the string resourcesReplacing the button textGetting a public resources classPerforming the localizationSetting the initial startup languageResponding to the button clickApproach #2: Localization with XAML ResourceDictionary and LocBamlAdding a UICulture tag pair to the project configuration Setting the NeutralResourcesLanguage Attribute in the projectAdding the ResourceDictionary to the projectMerging the ResourceDictionary into the applicationAdding UId's to your XAMLExtracting the Resources to a .CSV file using LocBaml.exeGenerating the localized assembly and installing itSetting the current thread's UI CultureReplacing the button text with a DynamicResourceWhere are we now?

Localizing WPF Applications using Locbaml

Introduction Background. WPF Localization - On-the-fly Language Selection - Essential XAML. Dispose of a WPF UserControl (ish) I've been playing with WPF a little bit, and quite frankly got a bit stuck, (Meh!

Dispose of a WPF UserControl (ish)

Who'd have thought). The problem is as follows: NET.2971 - WPF Bitmap Converter. S blog » C#, WPF – Fast image resize. Resizing images from the server using WPF/WIC instead of GDI+ - Tales from the Evil Empire. Caution: Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service.

Resizing images from the server using WPF/WIC instead of GDI+ - Tales from the Evil Empire

Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions. Kind of scary, isn’t it? Nobody likes diminished performance and run-time exceptions. But when you need to generate thumbnails from managed code, what other choices do you have? There used to be two: using interop with native APIs (which won’t work in medium trust) or writing your own image manipulation library from scratch.

Since WPF was introduced into the .NET framework, there has been a third possibility that will be the topic of this post. Before we look at that, let’s put things in perspective: there are LOTS of applications and components out there that are using GDI+ (or more accurately its System.Drawing managed code expression) and they work just fine. So let’s go and resize images. Jeff Wilcox – Build a highlighting AutoCompleteBox (like IE8 and Firefox 3) in 5 minutes.

Downloads: Highlight Searched Text in WPF ListView. Introduction I wrote this as an inspiration for how to search in Microsoft Outlook.

Downloads: Highlight Searched Text in WPF ListView

Imagine that you have a ListView in a WPF application and you are looking for a text in the individual items. It would be useful to highlight the text. The code used in this demo can be adjusted wherever it's appropriate and the highlighted text is displayed by using the TextBox control. Search and highlight any text on WPF rendered page - Just code - Tamir Khason. Monday, May 12, 2008 8:12 PM Tamir Khason Today we’ll speak about how to search and select text on WPF page. This is not about how to search data sources, or how to search for data. This is visual search. Like this one. Creating a Piano Roll in WPF Part 3 - Data Binding. I have posted a couple of times on creating a Piano Roll control in WPF.

Creating a Piano Roll in WPF Part 3 - Data Binding

(Part 1 and Part 2). Today I want to take a slight digression and ask whether this could be accomplished more elegantly using a data binding approach. Zoom and page changed events for FlowDocumentPageViewer. WPF Tips'n'Tricks #6: Preventing ScrollViewer from handling the mouse wheel. In the category of the pot talking to the pan, I present you ScrollViewer. It's the main control to implement scrolling in your templates, but it's also the one not respecting a very fundamental rule of scrolling: if you're done scrolling, let your parent scroll! Not only does ScrollViewer handles the mouse scrolling even when no more scrolling is needed, but it also does so when there's nothing to scroll, or worse when it is told not to scroll!

Let's take an example XAML file. <Window x:Class="CaffeineIT.Blog.ScrollViewerExample.Window1" xmlns=" xmlns:x=" Routed Event Viewer « Karl On WPF – .Net. Understanding the order in which routed event handlers are invoked is an important WPF programming concept. I wrote the below demonstration program as a visual aid for my WPF presentations and wanted to share it.

It allows the user to select which routed event handlers to handle, which event handler will mark the routed event as handled and simulates code running in the handler. If you have not read the MSDN topic “Routed Events Overview” I strongly suggest that you do. Focus a Virtualized ListBoxItem - Matt Hamilton. One of the primary tenets of Halfwit is that it should be completely drivable from the keyboard.

That means that while I code it I have to pay very close attention to where the keyboard focus is, and what's currently "selected". To that end, it's important that when you switch away from a timeline and then switch back, the same tweet that you previously had selected is still selected, and it still has keyboard focus so you can navigate around it with the up and down arrow keys. WPF Commands Everywhere - Essential WPF. Blendable MVVM: Commands and Behaviors : Compiled Experience : .NET Development in New Zealand.

In the first post of the series we looked at using Binding expressions to display data from the ViewModel on our screen. C# - How to add a Blend Behavior in a Style Setter. Bea Stollnitz » Are there any tricks that will help me improve TreeView’s performance? – Part III. Customizing WPF TextBox Not Easy, But Possible « Dale Barnard on WPF/Silverlight/Windows Phone 7. For several days, I looked for hooks into the Windows Presentation Foundation (WPF) System.Windows.Controls.TextBox control to display shadowed text: WPF does not make the shadow effect easy. Changing the Foreground property can change the text color to any brush (even to a video or an image brush), but it does not achieve the shadow effect. AttachedCommandBehavior V2 aka ACB « C# Disciples. YOUAfter publishing my AttachedCommandBehavior library, (you can read about this here), some WPF Disciples recommended some new features to make the library cover more use cases.

Thanks William Kempf your input was amazing! ListBox – Automatically scroll CurrentItem into View « michlG's Blog. /// <summary> /// This class contains a few useful extenders for the ListBox /// </summary> public class ListBoxExtenders : DependencyObject #region Properties. Wpf - ListBox List Rotation. Browse by Tags - Dan Crevier's Blog. Foundations: Using Templates to Customize WPF Controls. Foundations. Functional Fun: Hooking up Commands to Events in WPF. WPF Commands Everywhere - Essential WPF and Young Brothers.

It has been a long time since I’ve written something in my blog and there are many items in my stack. Unfortunately, I don’t have the time to pop all, so I’ll try to peek few of my best thoughts. Brent Says… » Blog Archive » MVVM Fabric: Using TriggerAction. A few days ago, I wrote about using MVVM Fabric’s ActionCommand. Commanding can be useful with controls that provide a Command property, such as Buttons and MenuItems. However, commanding doesn’t help when you want to wire up arbitrary events to your view model. Silverlight and WPF Behaviours and Triggers - Understanding, Exploring And Developing Interactivity using C#, Visual Studio and Blend. Download related source code. Anvaka. Привет, друзья! Rockford Lhotka - WPF. A Simple, Integrated WPF Help System. HTML help from within WPF applications - Bragi. Word to XAML Converter. Showing XPS Documents with DocumentViewer Control in WPF.

Обзор фигур и базовых средств рисования в приложении WPF. Path Markup Syntax. Path in WPF. WPF - Themes and Control Libraries - Part 2 - Nidonocu - typeof(Tea) Catel - Part 2 of n: Using WPF Controls and Themes. Part 3: Emissive Materials, Polygons, And Storyboards. Advanced WPF: Understanding Routed Events And Commands In WPF.