如何将属性绑定到文本框?

时间:2019-05-18 21:28:07

标签: c# wpf xaml binding

我的xaml.cs

public partial class ViewersWindowEditor : Window
{
    public ViewersWindowEditor()
    {
        InitializeComponent();
    }    

    private static Logger _logger = LogManager.GetCurrentClassLogger();
    public VIEWER SelectedViewer { private get; set; }

    private void ViewersWindowEditor_OnLoaded(object sender, RoutedEventArgs e)
    {
        //throw new NotImplementedException();
    }
}

和此xaml代码:

<StackPanel Name="spField" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" DataContext="{StaticResource SelectedViewer}" >
    <TextBox Name="txtName" Width="150" Text="{Binding NAME, Mode=OneWay}">
</StackPanel>

我想绑定txtName = SelectedVIewer.NAME

0 个答案:

没有答案