I have a textbox in my xaml for an ID field that is pulled from a datasource. I want this value to be readonly so that users can't change this value. I have a button for the user to add a new object which of course will require an ID. I have a bool property on my object "IsNew" that gets set to true when the user clicks the "Add New" button. When that button is clicked, I want this textbox to be editable. So basically, when "IsNew = true". How can I accomplish this?
//My Xaml for the textbox: <TextBox x:Name="ID" Text="{Binding SelectedRecord.ID}"/> //Xaml for the button <Button x:Name="AddNewRecordButton" Grid.Column="1" Margin="20,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Bottom" HorizontalContentAlignment="Left" Height="24" Width="90" Command="{Binding AddNewRecordCommand}" CommandParameter="{Binding ElementName=window}"/> //Code for the command method public void AddNewRecord(object parameter) { var newRecord = new StockingReason(); Records.Add(newRecord); SelectedRecord = newRecord; newRecord.IsNew = true; var control = parameter as IFocusable; control?.SetFocus(); }