There is a viewmodel.
public class VM_searchResult : DependencyObject, INotifyPropertyChanged { private CCard createdCard; private Commands selectSpravInfo; public Commands SelectSpravInfo { get { return selectSpravInfo ?? (selectSpravInfo = new Commands(obj => { W_selectSprav wSelectSprav = new W_selectSprav(obj as CCard); wSelectSprav.ShowDialog(); })); } } public CCard CreatedCard { get { return createdCard; } set { createdCard = value; OnPropertyChanged("CreatedCard"); } } } View
<StackPanel Orientation="Horizontal" DataContext="{Binding CreatedCard}"> <TextBlock Text="Номер регистрации:" Margin="10,7,0,0" TextWrapping="Wrap" VerticalAlignment="Top"/> <TextBox x:Name="TB_regnum" Text="{Binding Regnum}" Margin="10,7,0,0" VerticalAlignment="Top" MinWidth="90"/> <TextBlock Text="База данных:" Margin="10,7,0,0" TextWrapping="Wrap" VerticalAlignment="Top"/> <Button x:Name="B_selectDB_card" Command="{Binding SelectSpravInfo}" CommandParameter="{Binding CreatedCard}" Content="..." Margin="10,7,0,0" VerticalAlignment="Top" Width="20"/> <TextBox x:Name="TB_db_card" Text="{Binding Bdncpi._name}" Margin="10,7,15,0" TextWrapping="Wrap" VerticalAlignment="Top" IsEnabled="False" MinWidth="200"/> </StackPanel> In such a situation, the SelectSpravInfo command is searched in the context of a CreatedCard , which is not there actually. Hence the question, how to get out of this situation? No way, somehow prescribe the context of each textbox.