Full Width Toolbar

As I ventured into WPF world, some things annoyed me more than others. One of those things was inability of toolbar to have no grip and to be full width.

After some time I found solution for grip problem. Just put toolbar in toolbar tray and set IsLocked attribute to true.

<ToolBarTray IsLocked="True">
    <ToolBar>
        ...
    </ToolBar>
</ToolBarTray>

Extending it’s width proved to be little bit more engaging. It took me a while to notice ActualWidth property of ToolbarTray control. As name says, it will return you actual width of ToolbarTray.

Since we want toolbar to span whole window, it should be inside DockPanel (and docked to top). Synchronizing ActualWidth of ToolbarTray and our Toolbar is then solved by simple data binding:

<DockPanel?
    <ToolBarTray IsLocked="True" DockPanel.Dock="Top">
        <ToolBar MinWidth="{Binding RelativeSource={RelativeSource AncestorType={x:Type ToolBarTray}}, Path=ActualWidth}">
            ...
        </ToolBar>
    </ToolBarTray>

    <Grid>
    </Grid>
</DockPanel>

Sample with everything done (and few things more) is here.

Got a Key?

Illustration

Starcraft II has it’s release date confirmed. It will be available for general public on 27th July. Of course that probably means that I (a resident of Croatia) will not get it until some time later.

Detecting 64-Bit in .NET 4.0

In previous versions of .NET we could check whether process is 64-bit or not. It is not obvious solution - we check length of pointers.

With .NET 4.0 there are two new properties in Environment class. Is64BitProcess returns true if we are currently running in 32-bit mode. It is equivalent to our old-style check of IntPtr.Size == 4.

Is64BitOperatingSystem is something completely new. It will return true if operating system is capable of running 64-bit programs. This opens possibility of detecting 64-bit environment even if we run in 32-bits ourself. It will not be used often but it is good thing to have when e.g. running other processes.

Windows Phone Developer Tools

Illustration

Some time ago Microsoft gave us CTP version (you might call it alpha) of Windows Phone development environment. Unfortunately, that version of Visual Studio 2010 Express for Windows Phone was not compatible with Visual Studio 2010 RTM.

Last days of April finally brought refreshed CTP with that particular problem solved.

Happy development.

Some Things Never Change

Illustration

I played a little with Windows Phone 7. I will save my opinions about Windows 7 as development platform for some other post. This time I want to rant about one thing that survived even into new and polished Windows Mobile.

I am not sure what situation is in USA, but in Europe we tend to have more than one mobile phone. I have two of them. Quite few people that I know also have two mobiles. My sister has total of four.

Excessive? Maybe. However, this is reality for parts of world that are not “mobile challenged”.

Windows Phone 7 does not recognize that reality. There is only one field for Mobile phone entry. I usually use Pager as substitute field (pagers never took hold here) but that way you lose ability to quickly send SMS and anyhow that trick is good for only one additional mobile. What with others?

Windows Phone 7 is probably singled out without reason since I do not recall any Windows Mobile version that worked “properly”. Problem is actually much deeper and has root in Outlook and Exchange. Until those two start their life in 21st century nothing will change.

Sometimes I miss my good old Nokia.