Questions tagged [findancestor]

27 questions
23
votes
4 answers

What exactly does WPF Data Binding's "RelativeSource FindAncestor" do?

I am currently working within a WPF user control (the root element of my XAML file is "UserControl"), which I know is being hosted inside a Window. How can I access a property of the Window using data binding? Does anyone know why simply
user200783
  • 13,722
  • 12
  • 69
  • 135
8
votes
4 answers

Setting style based on existence of an ancestor type

I have 2 sets of TextBlocks some of them are in an ItemControl and some of them are not. I want to make a style (just based on type) which sets the background of the TextBlock if its ancestor is an ItemControl. I can do it using the following code…
Fred Jand
  • 699
  • 7
  • 25
7
votes
1 answer

Using FindAncestor from within an Itemscontrol datatemplate to find a textblock outside of the datatemplate

I have a ItemsControl that's bound to an object, within the datatemplate of the ItemsControl i have two textblocks, I want to bind the first textblock's text property to another textblock that sits outside this ItemsControl. I have tried finding…
Dayman
  • 73
  • 1
  • 1
  • 3
6
votes
3 answers

How can I Improve performance of RelativeSource FindAncestor?

Is FindAncestor searches an element in whole Visual tree of Window? If yes, then how can I improve on it ?? Is binding data error thrown if we access property of object by finding an element with Find Ancestor & no such a element exist? If yes, then…
Amol Bavannavar
  • 2,062
  • 2
  • 15
  • 36
6
votes
1 answer

WPF Triggering by ancestral property

I would like to use trigger the trigger, but i need to select the ancestor's property, for example: Only that the State property need to be the…
Cybered
  • 98
  • 1
  • 8
4
votes
1 answer

Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='MahApps.Metro.Controls.Glow', AncestorLevel='1''

I've created one wpf application in which I've used MahApps Metro tools for my view window. My application is working perfectly, but binding error is shown in output window. I've not used any code which is mentioned in that error. Error is: Cannot…
Dinesh
  • 507
  • 4
  • 14
  • 23
3
votes
1 answer

WPF Multibinding RelativeSource Findancestor evaluation performance

In the case of the following MultiBinding expression how many times will the binding engine search for the DataGrid ancestor IF the PropB is changed multiple times?
Yoghurt
  • 295
  • 3
  • 10
2
votes
1 answer

Why is FindAncestor binding not working in GridViewColumn?

I'm trying to create my own GridViewColumn and having some issus with binding. Can someone explain to me why the following Header-binding does work
Florian Gl
  • 5,984
  • 2
  • 17
  • 30
2
votes
2 answers

Trouble binding a checkable MenuItem to parent Window's Topmost (always on top) property

I can't figure out where I'm going wrong here. Hopefully one of you can help. I have a Window that contains a TabControl. The TabControl has a ContextMenu with a checkable item for "always-on-top" behavior. I want to bind this checkable item to…
Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
1
vote
1 answer

Binding to a cutom property of the template parent

Q: How do I bind to a custom property of the template parent from a child control's style DataTrigger I've been scratching my head over this one for a couple of days. I have a databound TreeView which uses a Style which has a Template. The TreeView…
Dominic
  • 62,658
  • 20
  • 139
  • 163
1
vote
1 answer

FindAncestor implementation in WP8 ListBox

I want to implement a Listbox binding directly and here is the code i used in WPF syntax
Sebastian
  • 4,625
  • 17
  • 76
  • 145
0
votes
2 answers

If the DataTemplate is nested in another Datatemplate it's hard the binding with a father-template property

Have youI know that the problem has been many times discussed in the web. But mine is a particular case and I still haven't found the right solution. Scenario: Silverlight 4 - A TreeView with data showed by two HierarchicalDataTemplate, one to show…
lamarmora
  • 1,116
  • 4
  • 16
  • 32
0
votes
1 answer

Programmatically creating a RelativeSource FindAncestor binding

I am writing some code which programmatically creates bindings on the fly, but I can't seem to read the value resulting from a binding whose RelativeSourceMode is set to FindAncestor. I was wondering if anybody has successfully created a…
FunnyItWorkedLastTime
  • 3,225
  • 1
  • 22
  • 20
0
votes
2 answers

ToolBar item DataTemplate binding RelativeSource search failing to find parent ToolBar

I have a ToolBar containing Buttons, some of the Buttons have only an Image for content, others have only Text. I am trying to bind the width property of the Button Image to a custom Property on my derived ToolBar class. It works sometimes but…
Hank
  • 193
  • 1
  • 10
1
2