开发者

How can I databind to a static CLR property?

开发者 https://www.devze.com 2022-12-30 09:02 出处:网络
I want to databind a textblock to some CLR objects so I can display details about a users system. Example:

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

精彩评论

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