private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var but = sender as Button; if (but != null) { var firm = but.CommandParameter as FirmModelWraper; if (firm != null) { DocGenerator.FirmaData(firm.CurrentFirma); } } }