OO初学者的绑定示例 [英] Binding Example for a OO beginner

查看:115
本文介绍了OO初学者的绑定示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几周来一直试图找到一篇不错的文章,简单地解释了WPF绑定,并通过一个实际解释正在发生的事情的工作示例。是的,那里有很多例子,但很多都涉及所涉及的所有内容的旧版本。



我正在尝试编写一个不是基于Web的应用程序,在VS2012上使用WPF和VB。



在这段代码我直接更新屏幕字段,但我想学习如何更新内存中的变量在屏幕上自动更新,我如何从这里到达那里 - 在简单的解释阶段



我是Pascal等语言的传统程序员,各种口味的基本和各种汇编,但从不C,当然不是OO



I have been trying for weeks to find a decent article that explains WPF Binding simply and with a working example that actually explains what is happening. Yes there are lots of examples out there but lots of those refer to older versions of everything involved.

I am trying to write an application, that is not web based, uses WPF and VB on VS2012.

In this bit of code i am updating a screen field directly, but i want to learn how to update a variable in memory and it update on the screen automatically, how do i get from here to there - In stages with simple explanations

I WAS a traditional programmer in languages such as Pascal, various flavours of Basic and various Assemblers but never C and certainly not OO

<Window x:Class="MainWindow" 

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

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

        Title="Test Bind" 

        Height="299" Width="500" WindowStartupLocation="CenterScreen">

    <DockPanel HorizontalAlignment="Stretch" LastChildFill="False" VerticalAlignment="Stretch">
        <DockPanel DockPanel.Dock="Top" Height="64">
            <Button Content="Button" Height="64" VerticalAlignment="Top" Width="75" Click="Button_Click" />
            <TextBox Height="64" Width="120" Text="TextBox1" x:Name="clickcount" />
            <TextBox Height="64" Width="120"  x:Name="textBox2" Text="{Binding Test, Mode=Default}" />
        </DockPanel>
    </DockPanel>

</Window>







Class MainWindow
  Public Shared clcount As Integer = 0

  Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    clcount = clcount + 1
    Me.clickcount.Text = clcount.ToString
  End Sub    
End Class

推荐答案

要绑定存储在内存中的变量并且在更改变量屏幕值的值时应该反映......... WPF中有依赖属性,或者你可以使用INotifyPropertyChanged接口。



首先你应该了解依赖属性和INotifyPropertyChanged然后它将很容易y OU。



如果您需要演示应用程序,我可以进一步详细说明。
To bind the variable stored in memory and on changing the value of variable screen value should be reflected ......... there is dependency property in WPF or you can use INotifyPropertyChanged interface.

First you should understand about dependency property and INotifyPropertyChanged then it will be easy for you.

If you need demo application i can elaborate further.


这篇关于OO初学者的绑定示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆