更改值时如何互相更改文本框(MVVM)

时间:2019-06-13 07:28:52

标签: c# mvvm

如何根据其他框来更改文本框?

在我有一个带有Icommand的按钮之前,现在当另一个文本框更改时,这些文本框也应该更改

keras

因此,总的来说,无论用户在哪个文本框中书写,我都希望在另一个系统中转换数字?

后面的属性如下:

    <TextBox Grid.Column="2" Grid.Row="2" Text ="{Binding Decimal, UpdateSourceTrigger = PropertyChanged}"/>
    <TextBox Grid.Column="2" Grid.Row="3" Text ="{Binding Dual, UpdateSourceTrigger = PropertyChanged}"/>
    <TextBox Grid.Column="2" Grid.Row="4" Text ="{Binding Hexa, UpdateSourceTrigger = PropertyChanged}"/>
    <TextBox Grid.Column="2" Grid.Row="5" Text ="{Binding Octa, UpdateSourceTrigger = PropertyChanged}"/>

1 个答案:

答案 0 :(得分:4)

我假设$("#field_name").select2({ placeholder: 'Select a data', allowClear: true, minimumInputLength: 3, tags: [], ajax: { url: '<your url>', dataType: 'json', type: "GET", quietMillis: 1000, delay: 900, data: function (term) { return { data:$('#field_name').val(), }; }, beforeSend: function() { $('#ajaxloading_c').css('visibility', 'visible'); $('#ajaxloading_c').css('display', 'block'); $('#ajaxloading_mask').css('display', 'block'); }, results: function (data) { return { results: $.map(data, function (item) { return { text: item.name, id: item.id } }) }; $('#select2-field_name-results li').first().remove(); }, complete: function() { $('#ajaxloading_c').css('visibility', 'hidden'); $('#ajaxloading_c').css('display', 'none'); $('#ajaxloading_mask').css('display', 'none'); $('#select2-field_name-results li').first().remove(); if($('#select2-field_name-results li:first').text() == 'No data Found'){ $("#select2-field_name-results li:first").css("pointer-events", "none"); } } } }); $('.select2-container--focus, .select2-container--default').css('width','70%'); 是您的模型-它将数字存储在内部,并正确管理数字转换。

最简单的解决方案是在ViewModel中触摸其中一个相关属性时只要求更新它们。

Number