Answer the question
In order to leave comments, you need to log in
How to supplement the code of one method with code from another?
There is a class with two methods.
Class: WindowActions - actions on a window.
Methods:
SetWindowSizeToContent - set window size by content.
SetWindowCenterAndSizeToContent - set window size to center and content.
(that is, this method is an exact copy of the method above + 1 line of new code)
You need to supplement the code of the second method with the code from the first. Of course, without copying, i.e. how to "inherit" a method (like a class). (Clearly, there is no method inheritance.)
public static class WindowActions
{
public static void SetWindowSizeToContent(Window window)
{
// Manually alter window height and width
window.SizeToContent = SizeToContent.Manual;
// Automatically resize width relative to content
window.SizeToContent = SizeToContent.Width;
// Automatically resize height relative to content
window.SizeToContent = SizeToContent.Height;
// Automatically resize height and width relative to content
window.SizeToContent = SizeToContent.WidthAndHeight;
}
public static void SetWindowCenterAndSizeToContent(Window window) //:SetWindowSizeToContent;
{
// Добавить сюда код из метода выше
window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question