标签: binding

WPF:数据绑定到参数化属性

鉴于此类/属性,我将如何编写 WPF 数据绑定表达式来获取myToken.DataItem("Phone")

Class Token
    Public Property DataItem(ByVal name As String) As Object
        Get
            If m_DataPoints.ContainsKey(name) Then Return m_DataPoints(name) Else Return Nothing
        End Get
        Set(ByVal value As Object)
            Dim oldValue = DataItem(name)
            If Object.Equals(oldValue, value) Then Return
            m_DataPoints(name) = value
            OnPropertyChanged("DataPoint")
        End Set
    End Property
End Class
Run Code Online (Sandbox Code Playgroud)

vb.net wpf binding

1
推荐指数
1
解决办法
6369
查看次数

如何将 CommandParameter 绑定到 DataTemplate 中父控件的 x:name?

我的 View XAML 中有以下内容

<GroupBox Grid.Row="0" Header="Aktionen bei Prüfung Aufbau">
    <ContentControl Content="{Binding BuildUpActions}" ContentTemplate="{StaticResource FullActionListTemplate}" x:Name="BuildUp"/>
</GroupBox>

<GroupBox Grid.Row="1" Header="Aktionen bei Prüfung Abbau">
    <ContentControl Content="{Binding TearDownActions}" ContentTemplate="{StaticResource FullActionListTemplate}" x:Name="TearDown"/>
</GroupBox>
Run Code Online (Sandbox Code Playgroud)

DataTemplate 在单独的资源中定义

<DataTemplate x:Key="FullActionListTemplate">
    <DockPanel LastChildFill="True">
        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="Neuer Ausgang" Style="{StaticResource ButtonRowStyle}"
                    Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=DataContext.NewFullIOCommand}" 
                    CommandParameter="{Binding **?HOW?**}"
                    />
            <more buttons here...>
        </StackPanel>
        <ContentControl Content="{Binding}" >

        </ContentControl>
    </DockPanel>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)

命令在 ViewModel 中定义

    public ICommand NewFullIOCommand
    {
        get
        {
            if (this._newFullIOCommand == null)
            {
                this._newFullIOCommand = …
Run Code Online (Sandbox Code Playgroud)

wpf binding datatemplate

1
推荐指数
1
解决办法
6706
查看次数

List&lt;string&gt; 在发生变化时不更新 UI

<ListBox x:Name="MainList" HorizontalAlignment="Left" Height="468" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" ItemsSource="{Binding Items,Mode=TwoWay}" DisplayMemberPath="Name"/>



[Serializable()]
public class MYcontainer : INotifyPropertyChanged,ISerializable
{
    private List<MYClass> _items = new List<MYClass>();
    public List<MYClass> Items
    {
        get{ return _items;}
       set { this._items =value;
        OnPropertyChanged("Items");
    }
public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(string propertyName = null)
    {
        var eventHandler = this.PropertyChanged;
        if (eventHandler != null)
            eventHandler(this, new PropertyChangedEventArgs(propertyName));
    }  
}
Run Code Online (Sandbox Code Playgroud)

当我将一个项目添加到“项目”时,UI 不会更新,绑定工作正常,因为如果我关闭窗口并再次打开它,新项目会正确显示。

我究竟做错了什么?我知道如果我使用ObservableCollection它会正常工作,但不应该使用它List<>吗?我已经在另一个窗口中有一个 string[] 属性并且它更新得很好。

c# wpf xaml binding

1
推荐指数
1
解决办法
1096
查看次数

将int绑定到javaFX中的Label

我正在尝试将int对象绑定到LabeljavaFX中,并且我不想将模型中的类型更改为IntegerProperty。我尝试了

mainActionLabel.setText(myintvar);

mainActionLabel.textProperty().bind(new SimpleIntegerProperty(myintvar.asString());

但是该值仅在我关闭并再次打开gui时更新,所以我猜绑定实际上并没有起作用,因为我想象它会使用setText方法进行更新。

还有另一种方法可以正确绑定它吗?

编辑:我只是试图删除

mainActionLabel.setText(myintvar);

行,但问题仍然像以前一样存在:已正确初始化,但不能实时更新。仅当我关闭窗口并重新打开它时。

binding javafx

1
推荐指数
1
解决办法
1547
查看次数

如何制作跟踪/控制任何布尔属性的QML切换按钮

我今天的QML/QtQuick练习是制作一个小ToggleButton小部件,我可以实例化它来监视指定的布尔QML属性的状态,并且当我点击ToggleButton时也切换该属性的状态.

到目前为止,我有我的ToggleButton组件:

// Contents of ToggleButton.qml
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4

Button {
    property bool isActive: false

    onClicked: {
        isActive = !isActive;
    }

    style: ButtonStyle {
        background: Rectangle {
            border.width: control.activeFocus ? 2 : 1
            border.color: "black"
            radius: 4
            color:  isActive ? "red" : "gray";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

....这是我的小测试工具,用于查看它是否按照我想要的方式工作:

// Contents of main.qml
import QtQuick 2.6
import QtQuick.Window 2.2

Window {
   visible: true
   width: 360
   height: 360

   Rectangle {
      property bool lighten: false;

      id:blueRect
      x: 32; …
Run Code Online (Sandbox Code Playgroud)

binding qt qml qtquick2

1
推荐指数
1
解决办法
2405
查看次数

如何在HTML中绑定Observable <any>单个类对象

我正在使用Angular4.我的打字稿文件中有一个Windows Timer订阅的observable.

    this.dynamicTime = new Observable<string>((observer: Subscriber<string>) => {
        setInterval(() => observer.next(this.computeTime()), 1000);
    });
Run Code Online (Sandbox Code Playgroud)

在我的HTML方面,我正在使用它.

<h1>
<div>{{ dynamicTime | async }}</div>
Run Code Online (Sandbox Code Playgroud)

这非常有效.

但是,如果我将变量"dynamicTime"的类型更改Observable<string>Observable<SomeClass>类对象.那它不起作用.有趣的是Windows计时器本身失败了.控件不会点击计时器功能"computeTime()".

这就是变化的样子.

    this.dynamicTime = new Observable<SomeClass>((observer: Subscriber<SomeClass>) => {
        setInterval(() => observer.next(this.computeTime()), 1000);
    });
Run Code Online (Sandbox Code Playgroud)

在HTML方面,

   <h1>
<div>{{ dynamicTime.someProperty | async }}</div>
Run Code Online (Sandbox Code Playgroud)

看起来HTML方面没有认识到"someProperty"."someProperty"在"SomeClass"类中声明为public.

不知道我在这里缺少什么.请指教.

谢谢亚当

binding timer observable angular

1
推荐指数
1
解决办法
1038
查看次数

Laravel Route模型绑定 - 空用户

我有路

http://192.168.10.15/user/33/edit
Run Code Online (Sandbox Code Playgroud)

我试图根据url id返回用户.

  public function edit($id, \App\User $user)
    {
        dd($user->id);
         return view('user.update');

    }
Run Code Online (Sandbox Code Playgroud)

id返回null,我该怎么做?

binding ioc-container laravel-5

1
推荐指数
2
解决办法
1783
查看次数

将按钮方法绑定到ENTER键

我在程序中遇到问题,我目前正在处理.该程序是一个登录系统,其中我有一个文本字段,一个密码字段和两个按钮(登录和退出).

我想将ENTER键绑定到"登录"按钮,这样无论什么是聚焦,如果我按下当前场景中的ENTER键,它将按下"登录"按钮.请记住,它仍然需要对鼠标点击做出反应.

不确定要上传哪些代码段,所以如果您需要,请询问.

java binding javafx button scenebuilder

1
推荐指数
1
解决办法
1101
查看次数

禁用按钮取决于JavaFX中另一个节点的子代数量

我需要根据某些子元素的数量禁用按钮。

我已经尝试过类似的事情,这是不对的:

HBox userDataHBox = new HBox(new Label("1"), new Label("2"), new Label("3"));
Button btn = new Button();
btn.disableProperty().bind(
  Bindings.notEqual(userDataHBox.getChildren().size(), 3)
);
Run Code Online (Sandbox Code Playgroud)

binding javafx

1
推荐指数
1
解决办法
25
查看次数

JavaFx:双向绑定数字,带加/乘/

我想双向绑定两个DoubleProperty,但不是真正的1:1,例如以1:1.2的比例绑定。

我需要类似的东西:

DoubleProperty x;
DoubleProperty y;

x.bindBidirectional(y.multiply(1.2));
Run Code Online (Sandbox Code Playgroud)

因此,每次设置x的值时,y值应为x * 1.2 ,每次设置y值时,x值应为y / 1.2

我该怎么做?

java binding javafx javafx-8

1
推荐指数
1
解决办法
49
查看次数