Answered by:
WPF Frame can not inherit value from parent

-
Hello
I previosly ask same question on http://social.msdn.microsoft.com/Forums/en-US/7b86f060-1bf3-407a-8b7f-3c2f75c2b39c/wpf-frame-can-not-inherit-value-from-parent link.
If the parent control defines a value for the property "Foreground". The WPF elements inside the Frame will not inherit that properties value.
If I add New Page to frame . then I change theme of window then it is not applying to page of the frame.
Why it is not inheriting from parent?
I need to make it null & again set theme on load of frame.
it cause performance slow of application.
Can you please help me for it?
Ref questions:
http://www.devexpress.com/Support/Center/Question/Details/Q459031
https://connect.microsoft.com/VisualStudio/feedback/details/520355/wpf-frame-control-stops-property-inheritanceI am not getting any proper solution for it.
Download video n code from here
https://drive.google.com/folderview?id=0B_UjcIVA766LZXgyclRxeVFQSFk&usp=sharing
I have created video as well as small Application showing that issue.
Here When I press Add New button New frame added to DockLayoutManager.
So theme is not applied to the child that is page & controls inside the page.
Frame stop theme applying to page.
Thanking you in advance..
RegardsVipul Langalia
Question
Answers
-
Hi Vipul,
From your description, I understood there is an issue regarding WPF Frame cannot inherit value
from parent.
I have an idea. I suggested you to create a class to manage the Color property. Parent
Frame and sub Frame’s Color property get from the class which managed the Color.
Firstly, we define a class to store color property, which we named this class Foreground;
Secondly, we create an instance of Foreground.
Thirdly, Binding the instance’ Foreground property to Frame.
I create a simple example to demonstrate what I said. Something looks like this,
XAML Code:
<Window x:Class="WPFFrameColor.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="200" Width="200"> <StackPanel> <TextBox x:Name="txtColor" Text="{Binding Path=Color, UpdateSourceTrigger=PropertyChanged}" Margin="5"/> <Button x:Name="BtnShow" Content="Show" Margin="5" Click="BtnShow_Click"/> </StackPanel> </Window>
Code Behind:
public partial class MainWindow : Window { ObservableCollection<Forground> collection = new ObservableCollection<Forground>(); public MainWindow() { InitializeComponent(); collection.Add(new Forground() { Color = "Red"}); this.DataContext = collection; } private void BtnShow_Click(object sender, RoutedEventArgs e) { MessageBox.Show(collection[0].Color); } } public class Forground { private string color; public string Color { get { return color; } set { color = value; } } }
Here are some references about this issue.
#WPF Passing a value from parent to a child 'page' hosted in a frame
#ObservableCollection<T> Class
http://msdn.microsoft.com/en-us/library/ms668604.aspxIf I misunderstood, do not hesitate to contact me.
Have a nice day!
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- Edited by Yang,Chenfei Friday, August 30, 2013 7:33 AM
- Marked as answer by Yang,Chenfei Thursday, September 05, 2013 2:52 AM