Wednesday, March 24, 2010

Trimmed TextBlock for Silverlight.

Download source files - here

Not always Silverlight TextBlock that contains long text has enough space for shows all this text. TextBlock clips text in this case - this behaviour isn't best way for this. Because I wait that TextBlock not only trims but also adds "..." to clipped text. WPF has brilliant property that helps to resolve this trouble - TextTrimming. I implemented this possibility for Silverlight and now want to present it for you. Furthermore I implemented ToolTip that shows trimmed text (only if text is trimmed!)
Enjoy!

UPD: I have just updated performance and behaviour when width defined zero.

Wednesday, February 24, 2010

Trips&Ticks: Easy way to navigate from XAML to class's definition.

Working with XAML code in VS2008 I have just found that I can easy jump to class's or property definition. If I press CTRL and click left mouse button on certain class or property in XAML I will be immediately switched to Object Browser (if it is class or property of .NET or external dll) or to class's or property definition in my code (if it is class or property from my sources).
Eugene Dolinskyy just pay my attention that "clear" VS2008 doesn't have this possibility. This feature is presented by ReSharper.

Monday, January 25, 2010

Zoom event for FlowDocumentPageViewer (corrected)

Download source files - here

When I wrote my article Zoom and page chaged events for FlowDocumentPageViewer I make mistake, you can read about it - there. However Martin offer solution for this problem. But I don't like this solution, overriding of OnPropertyChanged isn't best solution because this method is risen in many cases so any logic there is serious performance issue.
So how can we fix it in other way? We can find object of Slider in Visual Tree of FlowDocumentPageViewer and subscribe to ValueChanged event and call OnZoomChanged(); there.
Bingo! It fixes my trouble.

Sunday, January 24, 2010

Trips&Ticks: How to implement GroupName for RadioButton in WPF DataGrid's column?

Download source files - here

It is very easy. We should use DataGridTemplateColumn for this. My acquaintance requested to me show it. I added source code where implemented this.

Some notes:
  • You should turn off AutoGenerateColumns feature. In other case control will have duplicate values.
  • I recommend to turn off CanUserAddRows. In other case user can pick undefined row.
Enjoy Yulian ;).

Friday, January 15, 2010

Web access to Team Foundation Server.

I have been starting to work with Team Foundation Server as source control and bag tracking system for 2 month. In this time we migrated from one TFS to another. So sometime we needed access to both these servers (one as bug track, another as source control). I said to my manager about web access tool for TFS he heard it already that this tool is very cool but expensive.
It isn't truth. This tool is useful but full freeware! Because Microsoft Acquired TeamPlain 3 year ago :). When I tried to find it - I was a bit disappointed I couldn't found this tool - all links were broken. Little find out shows that TeamPlain is renamed to Team System Web Access. I founded article that describes How to: Install Team System Web Access (this page also contains broken link to installation of Team System Web Access :) ) and after all I found download page.
That isn't fresh news, but it is very upset that this useful tool is so hard for found.

Tuesday, November 24, 2009

Useful code snippets for WPF developer.

Download snippets - here

I want to share very useful in my opinion code snippets for WPF developers. Most of they were created my friend - Dmitrij Zakharov. Moreover I want to add a short description to each snippets.

Note:
The Code Snippet Inserter inserts a code snippet at the cursor location, or inserts a surround-with code snippet around the currently selected code.

Don't you know how to use code snippets? You should read next article - How to: Use Code Snippets (C#). You should copy the code snippets files to Installation directory\Microsoft Visual Studio 9.0\VC#\Snippets\1033\NetFX30 in your PC for start to use.

Let me start:
  • addowner - Adds owner to the dependency property that already exists.
  • defstyle - Code snippet for overriding DefaultStyleKey.
  • propa - Code snippet for an attached property using DependencyProperty as the backing store. It is the common code snippet that is delivered with installation of VS2008
  • propdp - Code snippet for a property using DependencyProperty as the backing store. It is the common code snippet that is delivered with installation of VS2008
  • propdpec - Code snippet for a property with value caching and events support using DependencyProperty as the backing store.
  • propdpr - Code snippet for a property using DependencyPropertyKey as the backing store.
  • routedcmd - Implements routed command executor.
  • routedevent - Declares and implements routed event.
PS: Do you want to know more? - read about Default Code Snippets.

Thursday, November 19, 2009

Zoom and page changed events for FlowDocumentPageViewer

Download source files - here

My old known Bala send to me this link.
Kent Boogaart has written an article that describes approach searching and highlighting text in FlowDocumentPageViewer - Search and Highlight Text in an Arbitrary Visual Tree. Unfortunate, two serious issues present there. I copy theirs description from msdn forum:
  1. When I change the pages of the FlowDocumentPageViewer, my Rectangular highlighted area remains the same and it is not sinking with the Text.
  2. When I zoom in or zoom out of the FlowDocumentPageViewer, the text gets zoomed but the Highlight rectangle remains in the same position.
Seems.. solution should be easy - just add DoSeach() method in PageChanged and ZoomChanged event handler methods of FlowDocumentPageViewer but it doesn't have events for notice these actions. So I decided just to implement these events :). FlowDocumentPageViewer doesn't have protected and virtual methods like OnZoomChanged or OnPageChanged. It was bad. But I found four protected and virtual methods that could help me they are OnNextPageCommand(), OnPreviousPageCommand(), OnIncreaseZoomCommand() and OnDecreaseZoomCommand(). When I added call to rise my events in theirs override methods I found that this approach wasn't work. It happened because command logic works through concurrency approach. I called the rise methods through BeginInvoke for delay the calls rise methods - and problem was solved.
You can download sources with fix above.

PS: I didn't have time for full investigate sources.. but one question. Why did Kent use SearchRectangle class? In my opinion common Rect is enough.