zoukankan      html  css  js  c++  java
  • wpf toggleSwitch 的只读属性

    xml code

    ---------------------------------------------

    <Page

        x:Class="UWPDemo.MainPage"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:local="using:UWPDemo"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        mc:Ignorable="d"

        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <Grid>

            <ToggleSwitch IsOn="{x:Bind isno, Mode=TwoWay}">on </ToggleSwitch>

            <Button Content="Button" Click="Button_Click" Margin="524,601,0,0" VerticalAlignment="Top" Width="434"/>

        </Grid>

    </Page>

    C# code

    -----------------------------------

    public sealed partial class MainPage : Page, INotifyPropertyChanged

        {

            private bool _isno;

            public event PropertyChangedEventHandler PropertyChanged;

            public bool isno

            {

                set

                {

                    if(PropertyChanged!=null)

                    {

                        PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(isno)));

                    }

                }

                get

                {

                    return _isno;

                }

            }

            public MainPage()

            {

                this.InitializeComponent();

            }

            private void Button_Click(object sender, RoutedEventArgs e)

            {

                _isno=!_isno;

                if (PropertyChanged != null)

                {

                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(isno)));

                }

            }

        }

  • 相关阅读:
    deepinmind(转)
    不知道数据库中表的列类型的前提下,使用JDBC正确的取出数据(转)
    shell 监控局域网的主机是否up(转)
    IntelliJ Idea中一个编译报错引发的
    Unity插件之NGUI学习(8)—— Table和NGUI尺寸转换为世界坐标系尺寸
    使用php-fpm状态页观察当前的php-fpm状态
    PHP连接Access数据库代码
    HDU 4107 线段树
    Effective C++之‘宁以pass-by-reference-to-const替换pass-by-value’
    xdebug的安装和配置方法
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14244146.html
Copyright © 2011-2022 走看看