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
Suraj Sararf
NA
12
8.2k
Can't access mainwindow class from page?
Feb 5 2015 10:49 AM
i have wpf app which have a mainwindow.xaml and a pages/page1.xaml .Page display on window using frame .window contain a textbox and when i try to give value to this textbox from page1 on button click then nothing happen in textbox . so what should i do?
i am using that code on button click-
Mainwindow.xaml
<Window x:Class="pp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:v="clr-namespace:pp.Pages"
Title="MainWindow" MinHeight="350" MinWidth="525"
Background="Transparent">
<Grid>
<TextBox Width="100" Height="40" Name="textbox1"/>
<Frame NavigationUIVisibility="Hidden" Name="Mainframe" Source="pages/page1.xaml" Margin="40"></Frame>
</Grid>
</Window>
Page1.xaml
<Page x:Class="pp.FileView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:v="clr-namespace:pp.Pages"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="FileView">
<Grid >
<Button Width="100" Height="40" Name="Btn" Click="Btn_click"/>
</Grid>
</page>
Page1.xaml.cs
private void Btn_Click(object sender, RoutedEventArgs e)
{
MainWindow mw=new MainWindow();
mw.textbox1.Text="hello";
}
Reply
Answers (
3
)
WPF stackpanel
wpf datagrid