TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jefferson JOURDAIN
NA
12
468
Wpf page change problem
Dec 31 2018 9:30 AM
Hello,
I am a beginner and I want to create an application with WPF (xaml and c #), so my problem is the page change. I go through a "ContentControl" which is on my mainwindows by changing the "Content" by a usercontrol window. When I call a method from a button that is on the mainwindows the page change is done but when I ask from a file usercontrol it does not work when I call the same method or is the problem? I already tried with a frame and same problem.
mainwindows.xaml
<Grid>
<DockPanel>
<ContentControl x:Name="Content" />
</DockPanel>
<Button Content="Button" HorizontalAlignment="Left" Margin="73,43,0,0" VerticalAlignment="Top" Width="75" Click="Logon_Click"/>
</Grid>
mainwindows.xaml.cs
private void Logon_Click(object sender, RoutedEventArgs e)
{
this.Changement<index>();
}
public void Changement<T>() where T : new()
{
Content.Content = new T();
}
When launching my application I click on the button to display the file index.xaml on my page and when I click on a button of the index page to call the method "Changement()" and change the Content by usercontrol and it does not change not the page. But if I change the index parameter when opening the application by any other file it works but since my usercontrol impossible. yet all the methods work well just the page that does not change.
Index.xaml.cs
public partial class index : UserControl
{
Mainwindows Main = new Mainwindows();
main.Changement<creation>();
}
Reply
Answers (
2
)
What are the Prerequisites to learn WPF?
HOW TO MAKE CONNECTION BETWEEN DATA IN XML AND SQLITE