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)));

                }

            }

        }

  • 相关阅读:
    Java中Date日期字符串格式的各种转换
    Redis集群搭建与简单使用
    Java中的Redis应用
    java的linux命令
    Lucene全文检索引擎
    设置Xshell中支持中文
    Java并发Fork-Join框架原理解析
    java线程
    Django-路由层
    Django简介
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14244146.html
Copyright © 2011-2022 走看看