  The spectral shift function of a pair of self-adjoint operators is expressed
via an abstract operator valued Titchmarsh--Weyl $m$-function. This general
result is applied to different self-adjoint realizations of second-order
elliptic partial differential operators on smooth domains with compact
boundaries, Schr\"{o}dinger operators with compactly supported potentials, and
finally, Schr\"{o}dinger operators with singular potentials supported on
hypersurfaces. In these applications the spectral shift function is determined
in an explicit form with the help of (energy parameter dependent)
Dirichlet-to-Neumann maps.
