zoukankan      html  css  js  c++  java
  • Element to Element Binding

    To help explain element to element binding in Silverlight, let's build a very simple application. The application will include a buttona a checkbox. When the checkbox is checked, the button is enabled, when the checkbox is unchecked. the button is disabled. Let's get started.

    1. Create a silverlight application in VS 2010. Name the project ElementBinding and allow VS to create a Web application project to host your application.

    2. Edit the mainPage.xmal file to add a StackPanel to the root Grid. Place a ToggleButton and CheckBOx named EnabledButton within that StackPanel so the ToggleButton appears above the CheckBox. Add a margin of 20 on the StackPanel and 2 on the ToggleButton and CheckBox to add some spacing between the controls. The Code for the page follows:

    <Grid x:Name="LayoutRoot" Background="White">
            <StackPanel Margin="20">
                <ToggleButton Margin="5" Content="Click to Toggle" />
                <CheckBox Margin="5" Content="Enable Button" IsChecked="True" />
            </StackPanel>
        </Grid>

    3. Next, we need to bind the ToggleButton's IsEnabled property to the checkbox's IsChecked property. We will do this with one way binding as described earlier before, and we will set the ElementName to EnableButton, which is the name we gave our CheckBox. The updated source code should nwo look like the following:

    4. That is it! No coding is required for this demo. Run the sample and will see that the ToggleButton is enabled.

    5. Now uncheck the Enable Button Checkbox and you will see that the ToggleButton is no longer enabled.

  • 相关阅读:
    B题 hdu 1407 测试你是否和LTC水平一样高
    A题 hdu 1235 统计同成绩学生人数
    hdu 1869 六度分离(最短路floyd)
    hdu 2795 Billboard(线段树+单点更新)
    hdu 1754 I Hate It(线段树)
    hdu 1166敌兵布阵(线段树)
    hdu 1556(线段树之扫描线)
    Contest2073
    中南oj String and Arrays
    51nod 1459 迷宫游戏 (最短路径—Dijkstra算法)
  • 原文地址:https://www.cnblogs.com/jerrychenfly/p/2139305.html
Copyright © 2011-2022 走看看