Do you want the view to be the same regardless of the window's resolution? You can use a fixed view and it will stretch to fit the window. This has an added benefit that all of the co-ordinates that you use don't need to be altered depending on the window's size. A down-side is that you no longer have co-ordinates that match the pixels exactly. However, you can use multiple views in one window so you can use a separate view for things that must have "pixel perfect" positioning/sizing, for example.
If all you want to do is match the view's aspect ratio to the window resolution's ratio, you can divide the window width by the window height to get the window ratio and then multiply that ratio by the view's height to get a new view width.
For example (in code):
// get view from window although you may want to use a specific view instead.
sf::View theView = window.getView();
// calculate window's ratio
const float windowRatio = static_cast<float>(window.getSize().x) / window.getSize().y;
// calculate a new view width so that the view's ratio would match the window's ratio
const float newViewWidth = theView.getSize().y * windowRatio;
// apply the new width. You may wish to also adjust the view's centre; this depends on how you're using the view.
theView.setSize({ newViewWidth, theView.getSize().y });
// use the new, adjusted view
window.setView(theView);
Note that you may wish to do this the other way around - that is, to calculate a new height from the width instead. That depends on your preference.