我想调用 onClick 事件并将 Textbox 对象从 .xaml 代码传输到事件处理程序。那可能吗?
我会试着说明,
这是我的 Main.xaml.cs 代码:
<Button x:Name="VideoTargetBtn" Content="Browse..." HorizontalAlignment="Left" VerticalAlignment="Top" Width="89" Click="VideoTargetBtn_Click" Height="27" Margin="10,13,0,0"/>
<TextBox x:Name="videoTargetPathTxt" Height="27" TextWrapping="Wrap" VerticalAlignment="Top" IsReadOnly="True" Margin="117,13,21,0"/>
这就是我想要做的:
private void VideoTargetBtn_Click(object sender, RoutedEventArgs e, TextBox currTextbox)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
bool? fileIsSelected = saveFileDialog.ShowDialog();
if (fileIsSelected == true)
{
currTextbox.Text = saveFileDialog.FileName;
}
}