Custom Page Classes / Programmatic Reuse

Wizard for WPF Forum

Posted 12 years ago by Joe Lozina
I am trying to use the Programmatic Reuse functionality in the example given and I am wondering how do I get access to controls(ie. text) inside the ItemEntryPage if i would like to change the visability.
I am trying to hide the following textbox

<TextBox Grid.Row="2" Grid.Column="1" Width="100" Margin="0,7,0,0" x:Name="description" Text="{Binding Description}"></TextBox>

TextBox description= (TextBox)this.FindName("description");
description.Visibility = System.Windows.Visibility.Hidden;
I tried this but it returns a null reference


Comments (2)

Posted 12 years ago by Joe Lozina
Ive tried to get the using the following but couldnt get the FrameworkElement/templatedParent using the DataTemplate.FindName(string name, FrameworkElement templatedParent) method. Can you let me know why this isnt working or suggest a solution?

Code I'm trying to use is

DataTemplate dataTemplate = this.ContentTemplate;
TextBox tb = (TextBox)(dataTemplate.FindName(("description", ????)); // ???? how do i get the templatedParent
Also, I noticed that I wasnt able to add the x:key attribute of the DataTemplate in the ItemEntryPage XAML, is there a reason for this?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Joe,

I think this article does a good job of explaining what you need to do:

Also, x:Key can only be set in resource dictionaries, not in objects that are applied to setters.

Actipro Software Support

The latest build of this product (v2020.1.0) was released 28 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.