I started to learn C# few days ago and I am facing some issues with WPF.
Currently I am trying to create a small WPF Application that receives a text file and analyzes the content. I already developed the classes for performing the analysis but I have some issues with the GUI. Additionally, I already developed the same Application on Windows Forms yesterday but now the same app (the code is adjusted to WPF standard) isn't working properly in WPF.
The different "pages" of the Form are seperated in Panels.
After starting the app the Window displays a text and a button. This button opens a fileDialog and allows the user to choose a text file from his computer. After that the analysis starts. The whole process is done by a backgroundworker to keep the GUI responsive. Now when the new page with a progress bar and few buttons should appear, nothing happens or it doesn't work properly.
I am setting the previous currentPanel.Visibility = Visibility.Hidden
and the new panel to nextPanel.Visibility = Visibility.Visible
.
What am I doing wrong? Are there better solutions to display different "pages"?
Thanks in advance!
EDIT: XAML-Code
<Grid Margin="0,0,0,-6">
<WrapPanel x:Name="StartPanel" VerticalAlignment="Center" HorizontalAlignment="Center" Height="Auto" Orientation="Vertical" Visibility="Visible">
<Label x:Name="StartLabel" Content="Word-Counter" RenderTransformOrigin="-0.339,0.349" FontSize="24" Tag="START" Height="60" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Label x:Name="StartSubText" Content="Hier werden Wörter aus deiner Text-Datei gezählt." HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="-0.339,0.349" FontSize="14" Tag="START" Margin="0,50,0,0"/>
<Button x:Name="StartBtn" Content="START" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.284,14.135" Width="80" Height="25" FontSize="16" Click="StartBtn_Click" Tag="START" Margin="0,100,0,0"/>
</WrapPanel>
<Canvas x:Name="ProcessPanel" Visibility="Hidden" HorizontalAlignment="Center" VerticalAlignment="Center" Width="800">
<ProgressBar x:Name="LoadingBar" Height="25" Width="500" Margin="0,182,0,233" Tag="DOING, FINISHED_LOADING" Panel.ZIndex="2" Canvas.Left="150" Canvas.Top="-192" Visibility="Hidden"/>
<Label x:Name="ProgressText" Content=" " FontSize="15" Margin="150,207,0,0" Tag="DOING, FINISHED LOADING" Panel.ZIndex="2" RenderTransformOrigin="1.168,-5.374" Canvas.Top="-192" Visibility="Hidden"/>
<WrapPanel x:Name="DoingProcessPanel" Width="800" Canvas.Top="-219" Height="432" Visibility="Visible" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Button x:Name="CancelProcessBtn" Content="Abbrechen" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Height="20" Margin="661,365,0,0" Tag="DOING" Visibility="Visible" Click="CancelProcessBtn_Click_1"/>
</WrapPanel>
<WrapPanel x:Name="FinishedProcessPanel" Width="800" Canvas.Top="-219" Height="432" Visibility="Visible">
<Button x:Name="ShowResultsBtn" Content="Anzeigen" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Height="20" Margin="661,365,0,0" Tag="FINISHED_LOADING" Visibility="Visible" Click="ShowResultsBtn_Click_1"/>
<Button x:Name="DiscardBtn" Content="Verwerfen" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Height="20" Margin="-150,365,0,0" Tag="FINISHED_LOADING" Visibility="Visible" Click="DiscardBtn_Click_1"/>
</WrapPanel>
</Canvas>
<StackPanel x:Name="ResultsPanel" Visibility="Hidden">
<DataGrid x:Name="dataGrid" Tag="RESULTS" Margin="0,0,694,10" Visibility="Visible">
<DataGrid.Columns>
<DataGridTextColumn Header="Wort" HeaderStringFormat="Wort"/>
<DataGridTextColumn Header="Anzahl" HeaderStringFormat="Anzahl"/>
</DataGrid.Columns>
</DataGrid>
<Button x:Name="FinishedBtn" Content="Zum Start" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Height="20" Margin="661,365,0,0" Tag="RESULTS" Click="FinishedBtn_Click"/>
</StackPanel>
</Grid>