微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

silverlight数据绑定

前台代码

<navigation:Page x:Class="story.databind"
           xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="
http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="
http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="databind Page" Loaded="Page_Loaded">
    <Grid x:Name="LayoutRoot" >
        <TextBox Height="23" HorizontalAlignment="Left" Margin="168,118,0" Name="txtBoxShow" VerticalAlignment="Top" Width="120" />
        <Slider Height="23" HorizontalAlignment="Left" Margin="168,208,0" Name="slSource" VerticalAlignment="Top" Width="120" />
    </Grid>
</navigation:Page>

 

 

后台代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using System.Windows.Data;

namespace story
{
    public partial class databind : Page
    {
        public databind()
        {
            InitializeComponent();
        }

        // 当用户导航到此页面时执行。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
          
        }

        private void Page_Loaded(object sender,RoutedEventArgs e)
        {
            Binding bind = new Binding("Value");
            bind.Mode = BindingMode.TwoWay;
            bind.source = slSource;
            txtBoxShow.SetBinding(TextBox.TextProperty,bind);
        }

    } }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐