背景:我有一个使用datagrid显示数据的项目,datagrid有一个rowdetail列,其中包含一个usercontrol.usercontrol有一些TextBox供用户输入和显示一些消息.
问题:我想在单击按钮时弹出usercontrol,并且popuped usercontrol与datagrid的rowdetail列中的usercontrol具有相同的上下文.这样做的目的是使用户易于与用户控件交互,因为rowdetail单元的空间是有限的.
usecontrol已实现,它可以在rowdetail单元格中正常工作.但是,我不知道如何在不改变其上下文的情况下弹出它,例如数据源,消息已经在TextBox中显示等等.任何人都可以给我一些建议吗?顺便说一句,我使用MVVM模式.
编辑: 这是RowDetailTemplate:
<DataTemplate x:Key="RowDetailTemplate">
<Grid x:Name="RowDetailGrid" HorizontalAlignment="Left" Width="850" Height="355" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<my:MyUserControl x:Name="myUserControl" />
<Button Grid.Row="1" Width="60" Height="25" Content="Pop Up"
Command="{Binding Path=PopupCommand}"/>
.....
</Grid>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
这是usercontrol(上面代码中的MyUserControl):
<UserControl x:Class="MyProject"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600">
<Grid>
<ScrollViewer Margin="0" HorizontalScrollBarVisibility="Disabled" >
<StackPanel>
<ItemsControl Grid.Row="0" ItemsSource="{Binding Output, Mode=OneWay}" FontSize="12">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding Path=.}" Foreground="White" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<DockPanel Grid.Row="1" LastChildFill="True">
<TextBox Text="{Binding Input, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextWrapping="Wrap"
BorderBrush="{x:Null}" SelectionBrush="{x:Null}" …Run Code Online (Sandbox Code Playgroud) 有一个叫做"-Tmp-"的名字,我怎么能cd进去呢?
当我使用时cd,它提示为:
$ cd -Tmp-/
cd: -T: invalid options
Run Code Online (Sandbox Code Playgroud)
有人可以帮帮我吗?