对话框中的TextBox不可编辑

时间:2011-07-22 18:42:16

标签: c# wpf xaml textbox

我正在尝试为用户创建一个对话框,以便将文本输入文本框。但由于某种原因,文本框不可编辑。我认为默认情况下文本框总是可编辑的。

Dialog是它自己的Window,从UserControl调用,它被添加到主窗口。

(对话代码)

<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>

(调用对话框的代码)

 // 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();

感谢您的帮助!!!

0 个答案:

没有答案