• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

在WPF中绑定类的属性至Label控件实现自动更新显示

开发技术 开发技术 3小时前 2次浏览

转载自

https://blog.csdn.net/vanwood/article/details/8077467

class:

public static readonly DependencyProperty _count =
	DependencyProperty.Register("count", typeof(int), typeof(DeviceOnlineStatusControl));
    
public int count
{
  	get { return (int)GetValue(_count); }
	set { SetValue(_count, value); }
}

xaml:

<UserControl x:Class="xx"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Das.MICS.Client.ViewModule.Controls"
             mc:Ignorable="d" 
             x:Name="Root"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Grid Height="36" Margin="10,0" VerticalAlignment="Top">
            <Label Content="总共:" HorizontalAlignment="Left" Margin="222,11,0,0" VerticalAlignment="Top" Width="39"/>
            <Label x:Name="Count" Content="{Binding ElementName=Root,Path=count}" HorizontalAlignment="Left" Margin="266,11,0,0" Width="52"/>
        </Grid>
    </Grid>
</UserControl>

程序员灯塔
转载请注明原文链接:在WPF中绑定类的属性至Label控件实现自动更新显示
喜欢 (0)