Simple Behavior for Binding to ActualWidth\ActualHeight

Monday, December 22, 2014

There are times when you want two or more elements in your XAML to share the same dimensions, usually you dint want to deal with static sizes and prefer that after an element got its size from the layout, all the other elements will be set to the same size. you can find the real sizes of an element quite easily by looking at its ActualHeight and ActualWidth properties, however those properties doesn’t behave nice with binding and attempting to bind an element to another element ActualWidth\ActualHeight will result in an expected results. to mitigate the problem I created...
no comments

Dependent DLLs are not copied if referenced only from XAML

Friday, September 19, 2014

I got a nasty exception in my project: A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: Could not load file or assembly 'AThirdParty, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. To illusatrate, this how my solution looked like: I have a control library that uses another control library (doesn't matter if in the same solution or from 3rd party).MyControlLibrary reference a control from the AThirdParty dll only in one of its user-controls xaml:<Grid> <aThirdParty:ThirdPartyControl/> </Grid> MyWPFApplication used the user-control from MyControlLibrary inside its...
no comments

WPF Lite TreeView

Thursday, September 18, 2014

I received a call from a client last week about bad performance in their WPF application. It turns out that they expected that some view that holds a tree will need to show a few tens of items BUT when they deployed it to customer site they were surprised that the amount of items was actually a few thousands. Long story short – WPF TreeView doesn't scale very good, trying to expand a node with thousands of sub-items can take a long time. Virtualization doesn't work either (especially if you work with .NET framework prior to 4.5) because it...
no comments

Dealing with reentrancy with DelegateCommand

Monday, May 19, 2014

many times in our application we have some button (or another command invoker) that is executing a long processing operation. today, with the power of Async Await its even easier to run these long operations while keeping the UI responsive. usually we will use some kind of DelegateCommand to bind our button to the ViewModels’ operation MissleLauncherView.xaml <Button  Command="{Binding LaunchMissiles, Mode=OneTime}"/>   MissleLauncherViewModel.cs private ICommand _launchMissilesCommand;public ICommand LaunchMissilesCommand {    get    {        return _ launchMissilesCommand ?? (_launchMissilesCommand = new DelegateCommand(           async (_) =>            {                await LaunchLongMissileAttack();            }));    } } this impose a very serious problem, while the LaunchLongMissileAttack method is working, nothing is preventing the command from being called again…and again…and again in...
no comments