1

I am trying to create a dialog for a user to enter in text into a textbox. For some reason though, the textbox is not editable. I thought textboxes always editable by default.

The Dialog is it's own Window, and is called from a UserControl which is added to the main window.

(Code for dialog)

<Window x:Class="TestApplication.View.SubjectDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Subject"
        Height="300"
        Width="300"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner"
        FocusManager.FocusedElement="{Binding ElementName=leftMarginTextBox}">
    <Grid>
        <Grid>
            <TextBox IsEnabled="True"
                     Height="23"
                     Name="NameField"
                     Margin="84,2,6,2">Some Name</TextBox>
            <Label Content="Subject Name"
                   Height="28"
                   Name="NameLable" />
        </Grid>
        <Button Name="CancelButton"
                IsCancel="True"
                Margin="12,222,186,12"
                Click="CancelButtonClicked">Cancel</Button>
        <Button Name="OKButton"
                IsDefault="True"
                Margin="186,221,12,12"
                Click="OKButtonClicked">OK</Button>
    </Grid>
</Window>

(Code calling the dialog)

 // Open up a dialog with feilds to fill in
SubjectDialog dialog = new SubjectDialog();

dialog.Owner = Window.GetWindow(this);
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(dialog);

dialog.ShowDialog();

Thanks for the help!!!

Mohit S
  • 13,723
  • 6
  • 34
  • 69
Michele
  • 113
  • 1
  • 1
  • 4
  • Does it work if you explicitly set it? IsReadOnly = "False" – Andy Jul 22 '11 at 18:48
  • Ok, I've figured it out! The label next to the textbox was actually very large and on top. So when I would try to click on the textbox, the label was getting the click, not the textbox. – Michele Jul 22 '11 at 19:25
  • If you found the solution, why don't you write an answer and accept it? – Tara Jan 06 '14 at 08:14
  • If you would have avoided using `Margin` as a layout instrument, it couldn't have happenend in the first place... – Onur Oct 02 '15 at 08:13

0 Answers0