Russ
Russ

Reputation: 12530

How can I databind to a static CLR property?

I want to databind a textblock to some CLR objects so I can display details about a users system.

Example:

TextBlock Grid.Column="1" Text="{Binding Path=System.Environment.OSVersion}"

How can I pull this type of thing off?

Upvotes: 0

Views: 175

Answers (1)

Jon
Jon

Reputation: 437376

Your only problem is that System.Environment.OSVersion is static.

This should work:

<UserControl 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    ...
    xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <TextBlock Text="{Binding Source={x:Static sys:Environment.OSVersion}}">
</UserControl>

Upvotes: 4

Related Questions