Author Archives: dmitriano

Implementation of WPF’s ICollectionView interface

The existing ICollectionView implementations in WPF, for example ListCollectionView, work very good in trivial cases, they even can sort and filter the items from the underlying collection, but they have some significant disadvantage: they do not keep the correct sort order of an item and they do not filter the item out if its property is changed until ICollectionView.Refresh() method is called explicitly.

To overcome this inconvenience I developed my own implementation of ICollectionView interface that listens to all its items property change events via WeakEventManager and fires corresponding collection change events to re-soft or re-filter the item if needed. It was not a very simple task for me, and I even debugged WPF source code a bit and realized that it works a bit strange, for example, ItemsControl cannot work with my ICollectionView implementation directly, instead it creates some CollectionViewProxy that wraps it and uses some proxy enumerator to access an item by index:

(more…)

Debugging .NET Framework with Visual Studio 2013

Visual Studio 2013 allows easily to debug .NET 4.5.1 Framework source code. If you use a previous version of .NET (4.5 or earlier) change the target .NET version of the your projects to 4.5.1 or higher. If you have some C++ CLI projects modify TargetFrameworkVersion attribute manually in all *.vcxproj files:

<PropertyGroup Label="Globals">
  ...
  <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
  ...
</PropertyGroup>

then go to Tools->Options->Debugging->General and check/uncheck the following options:

Debugging .NET Framework with Visual Studio 2013

(more…)

My experience with WPF

When I worked on some navigation system I developed so called “Control Panel” with various custom WPF controls:

(more…)

Using Visual Leak Detector with MS Visual Studio 2013

Go to Tools->Extensions and Updates, download and install Using Visual Leak Detector:

Using Visual Leak Detector

Create a header file, named, for example, CommonTools.h containing the following:

#pragma once

#include "C:\Program Files (x86)\Visual Leak Detector\include\vld.h" 

#pragma comment(lib, "C:\\Program Files (x86)\\Visual Leak Detector\\lib\\Win32\\vld.lib")

Include CommonTools.h in at least one file in all the C++ projects in your solution. Build debug version of the program. Visual Leak Detector will write the information on memory leaks to Output window when the program exits.

HwndHost is not clipped inside ScrollViewer

I created a simple white control with a black border derived from HwndHost (named LightGrid) and added it to ScrollViewer along with some other controls (replaced with “…”) as shown below:

<ScrollViewer HorizontalScrollBarVisibility="Disabled">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            ...
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            ...
        </Grid.RowDefinitions>
        ...
        <Border Grid.Row="6" Grid.ColumnSpan="2" Visibility="Visible" Height="200">
            <nc:LightGrid />
        </Border>
    </Grid>
</ScrollViewer>

It looks correctly in the lower scroll position, and it even can scroll inside ScrollViewer (it moves when I move the scroll bar), but when scrolled, it is not clipped so it obscures other controls:

(more…)

How I fixed “error LNK2005: _DllMain@12 already defined in msvcrtd.lib”

Today I got “error LNK2005: _DllMain@12 already defined in msvcrtd.lib” while linking some C++ CLI project with MFC support in MS Visual Studio 2013. As described in A LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++A LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++ article, I added /verbose:lib linker option:

MS Visual Studio Linker options

(more…)

Combining XAML and DirectX together in a WinRT application

With the release of Windows 8, Microsoft introduced a grate technology for combining XAML and DirectX together, letting us to place XAML controls over intensive real-time graphics, see DirectX and XAML interop (Windows Runtime apps using DirectX with C++) for more details.

You can easily download and build sample XAML SwapChainPanel DirectX interop sample demonstrating how it works. All that you need is Visual Studio 2013 with installed license. After the license is installed Visual Studio 2013 shows the following dialog:

Visual Studio 2013 license

(more…)

How to install Java Plug-in for FireFox browser on Windows

Probably it is a trivial question, but the answer is not always obvious. The main rule is to follow the right link like this: https://www.java.com/en/download/help/firefox_online_install.xml. As the result you will get:

JavaPlugin for FireFox

To check if it works or not follow this link: http://java.com/en/download/installed8.jsp.

What browser can work with Joomla 1.5 administrator panel?

Today I updated my FireFox browser and Joomla 1.5x administrator panel stopped working in it. Looks like Joomla 1.5x administrator panel contains some staff that prevents it from working in all modern browsers except Internet Explorer, or at least Internet Explorer is the only browser that displays message “Only secure content is displayed.” and button “Show All Content” enabling some insecure mode. To eliminate the need of pressing this button each time I open new page in administrator panel I went to “Internet Options->Security Tab->Miscellaneous->Display mixed content” and chose “Enable”:

enabling some insecure mode in IE

How to install updates to MS Visual Studio 2013

Select from the main menu of VS 2013 Tools->Extensions and Updates and in opened dialog press Update button under Product Updates:

updates to MS Visual Studio 2013

it will start downloading an installation file. When download completes close Visual Studio and run the installation file.