Binding between components with XAML and C #

4

I need that when selecting an item in a combobox, the textbox is released for editing and its completion is mandatory, as shown below:

Thisbindingisactivebyclickingthenewbutton,whereIchangetheIsEditingpropertyofmyViewModelclass.

classColectorsViewModel:Bindable{boolisEditing;publicboolIsEditing{get{returnisEditing;}set{SetValue(refisEditing,value);//ajustaoestadodoscomandosNovoColetorCommand.CanExecute=IsViewing&&selectedIndex>=0;ExcluirColetorCommand.CanExecute=IsViewing&&selectedIndex>=0;CancelarEdicaoColetorCommand.CanExecute=isEditing;GravarColetorCommand.CanExecute=isEditing;//NotificaaspropertiesIsEditingeIsViewingparaseremreavaliadas.OnPropertyChanged("IsViewing");
        }
    }
}

in XAML:

<TextBox x:Name="tbIntColetaVal" 
    Text="{Binding Colectors.IntervaloColetaVal, UpdateSourceTrigger=PropertyChanged}" 
    IsEnabled="{Binding IsEditing}" 
    HorizontalAlignment="Left" Height="23" 
    Margin="563,92,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="45" Grid.Column="1"
/>

and the Model:

public class Colectors : Bindable
{
    private int intervaloColetaVal;
    public int IntervaloColetaVal 
    {
        get { return intervaloColetaVal; }
        set 
        {
            SetValue(ref intervaloColetaVal, value);
            if (intervaloColetaVal <= 0)
            {
                AddError("O valor deve ser maior que zero(0)");
            }else
                RemoveErrors();
        }
    }
}
    
asked by anonymous 27.12.2018 / 17:45

0 answers