0

'助けてください'。編集ボタンが押されたときに、ビューモデルから別のビューを呼び出す必要があります。showdailog() もう使えません。このビューから別の子ビューを呼び出しています。

編集--> 削除</Button> </Border> </Border> </Border> </Border> </Border> </Border> </Border>-->

                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
        </Grid>
        </StackPanel>    
    </ScrollViewer>

    <Button Command ="{Binding SubmitCommand}" Name="Submit" Content="Search" HorizontalAlignment="Left" Margin="349,45,0,0" VerticalAlignment="Top" Width="75"/>
    <Button Command ="{Binding CloseCommand}" Name="Close" Content="Close" HorizontalAlignment="Left" Margin="535,379,0,0" VerticalAlignment="Top" Width="75"/>
    <Button Command ="{Binding ReLoadCommand}" Name="Reload" Content="ReLoad" HorizontalAlignment="Left" Margin="535,45,0,0" VerticalAlignment="Top" Width="75"/>
    <Button Command ="{Binding ClearCommand}" Name="Clear" Content="CLear" HorizontalAlignment="Left" Margin="443,45,0,0" VerticalAlignment="Top" Width="75"/>
    <Label x:Name="label" Content="Enter First Name or Last Name for Search" HorizontalAlignment="Left" Margin="84,18,0,0" VerticalAlignment="Top"/>
    <ComboBox ItemsSource="{Binding SelectedYear}" Name="comboBox" HorizontalAlignment="Left" 
              Margin="10,379,0,0" VerticalAlignment="Top" Width="120" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Item}">
        <!--SelectedItem="{Binding Item} -->
    </ComboBox>



</Grid>

ビューモデル:

    private ICommand _editRowData;

    public ICommand EditRowData
    {
        get { return _editRowData ?? (_editRowData = new CommandHandler(() => RowDataAction(), _canExecute)); }
    }


   private SecondWindowViewModel childView;
    public void RowDataAction()
    {
        childView = new SecondWindowViewModel();
        //MessageBox.Show("Edit Button Pressed");
        SecondWindow view = new SecondWindow()
        {
            DataContext = childView

        };

        childView.Labelcontent = "kala";

        view.ShowDailog();

        //view.ShowDailog() is giving me error. Please explain and provide me solve. 
4

1 に答える 1

0

ボタンのバインドを次のように変更します。

<Button Command="{Binding Path=DataContext.EditRowData, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" ... etc
于 2015-10-13T02:23:49.557 に答える