C# 无法使用命令参数绑定值
我需要从我的C# 无法使用命令参数绑定值,c#,wpf,xaml,mvvm,icommand,C#,Wpf,Xaml,Mvvm,Icommand,我需要从我的SubmitCommand中的TextBox标记中获取Text值 但我只得到一个空值。请帮助我了解在我的消息框中显示文本需要做什么 <UserControl> <Grid> <StackPanel Grid.Row="1" Grid.Column="1" Margin="0" FocusManager.Is
SubmitCommand中的TextBox
标记中获取Text
值
但我只得到一个空值。请帮助我了解在我的消息框中显示文本需要做什么
<UserControl>
<Grid>
<StackPanel
Grid.Row="1"
Grid.Column="1"
Margin="0"
FocusManager.IsFocusScope="true">
<TextBox
Name="linkTb"
DataContext="{Binding SelectedSite}"
IsManipulationEnabled="True"
TabIndex="0" />
<StackPanel
Orientation="Horizontal">
<Button
x:Name="submitButton"
Command="{Binding SubmitCommand}"
CommandParameter="{Binding SelectedSite}"
Content="Submit"/>
</Grid>
</UserControl>
此屏幕截图显示我的空消息框
,其中应包含以下文本:
绑定文本
属性,并将源属性(SelectedSite
)的UpdateSourceTracger
设置为PropertyChanged
,以便在每次击键时进行设置:
<TextBox
Name="linkTb"
Text="{Binding SelectedSite, UpdateSourceTrigger=PropertyChanged}"
IsManipulationEnabled="True"
TabIndex="0" />
<TextBox
Name="linkTb"
Text="{Binding SelectedSite, UpdateSourceTrigger=PropertyChanged}"
IsManipulationEnabled="True"
TabIndex="0" />
CommandParameter="{Binding SelectedSite}"