English 中文(简体)
铁锰和 W铁矿石 包装检查箱将财产检查给某类成员变量
原标题:IronPython & WPF: Binding a checkbox s IsChecked property to a class member variable

我已经看到许多类似的问题,即如何获得与检查箱一起具有约束力的数据,但我所看到的例子中的all出现在C#中,我似乎无法将数据转换到铁蓬。 因此,我有一个窗口中的检查箱:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Name="Test" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <DockPanel>     
        <CheckBox Name="bindtest" IsChecked="{Binding Path=o1checked, Mode=OneWay}"></CheckBox>
        <Button Content="Toggle" Name="Toggle" Padding="5"></Button>
    </DockPanel>
</Window>

并且,在<代码>本身.o1checked时,我想自动更新其成像价值:

class MaikoCu64(object):
    def __init__(self):
        self.o1checked = False
        ui.win[ Button ][ Toggle ].Click += self.Toggle_OnClick

    def Toggle_OnClick(self, sender, event):
        self.o1checked = not self.o1checked

(That ui Object is a category that has the xamlloaded into it as a dictonary of ui Control. 见here

因此,我如何做到这一点? 在通过MSDN具有约束力的文件(也见C#)阅读数小时后,我尝试增加:

import System
myBinding = System.Windows.Data.Binding("o1checked")
myBinding.Source = self
myBinding.Mode = System.Windows.Data.BindingMode.OneWay
ui.win[ CheckBox ][ bindtest ].SetBinding(System.Windows.Controls.CheckBox.IsCheckedProperty, myBinding)

它没有工作,但似乎至少有些意义。 我在正确轨道上发言吗?

最佳回答

财产应当使用公有财产接口。 See my blog, for an example how to implementing it in IronPython.

另外,还有一份银灯bug,载于“NET”或“铁Python”,造成一种错误,即除扼杀外,任何东西都应重新传播到观看。

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签