开发者

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 ca开发者_如何学Cn I pull this type of thing off?


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜