I was about to try Gerry's suggestion when I decided to test retriving the screen width with code and set the window size to it.
It worked, but I wonder, is there not a way to do this without using code in WPF?
Here is the code I used if someone is interested:
I have a DataGrid with a couple of DataGridTemplateColumns.
When I try to hit the Enter-key on my keyboard there is no new row created in the DataGrid.
I have other DataGrids with columns which are not DataGridTemplateColumns and I can then create new rows by hitting the Enter-key. So I assume the DataGridTemplateColumns in some way causing the problem.
I have made a reproducible code and I have made it public in this GIT-Gist.
* I use Fody PropertyChanged to handle all the INotificationPropertyChanged in my view models.
* The code should just be copy-and-paste.
The bindings between the View and the ViewModels also don't seem to work :S
But if you uncomment the row in the ViewModel's construcotor (please see line 60 in the MainWindow.xaml.cs), a new row in the DataGrid will be created. With this row, the bindings works as expected. I cannot understand why.
Here is the XAML-code. It maybe enough for you with only the XAML-code to solve this problem.
The benefit of asking "clear questions" is that you might get an "answer", instead of another "question" asking you to clarify your question. You must have a lot of time on your hands to be able to deal with just more questions (and no answers).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
I have a Storyboard at Window resources as shown below.
The Storyboard can be started with the following string which is placed in regular Button.
I'm working on a custom installation wizard. From it, I'm calling DISM to install IIS and ASP.Net if they're not installed. All the code in the installer class works fine when called from a console app. I'm now trying to put a simple UI on it.
There are 2 steps. Each step raises the event 'CurrentTaskChanged' with text "Installing IIS" or "Installing ASP.Net", and then during installation it raises a ProgressChanged event to send progress to the UI.
The problem is that none of the UI updates happen until the after the entire install process finishes.
Installer Class Code
InstallFeature("IIS", "/Online /Enable-Feature /FeatureName:IIS-DefaultDocument /All");
InstallFeature("ASP.Net", "/Online /Enable-Feature /FeatureName:IIS-ASPNET45 /All");
privatestaticvoid InstallFeature(string featureName, string args)
// Raise the task changed event so the UI shows what is installing
string dism = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "dism.exe");
if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
dism = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "sysnative", "dism.exe");
var process = new Process();
var startInfo = new ProcessStartInfo
UseShellExecute = false,
CreateNoWindow = false,
RedirectStandardOutput = true,
FileName = dism,
Arguments = args
process.StartInfo = startInfo;
process.OutputDataReceived += (sender, e) => HandleDISMOutput(e.Data);
process.StartInfo.Verb = "runas";
catch (Exception e)
privatestaticvoid HandleDISMOutput(object data)
if (data != null)
var info = data.ToString();
// Parse out the percent digits
info = info.Replace('[', ' ');
info = info.Replace(']', ' ');
info = info.Replace('=', ' ');
info = info.Replace(" ", "");
info = info.Replace("%", "");
double.TryParse(info, outdouble percent);
// Raise the percent completed event to update the progress bar in the UI