Click here to Skip to main content
15,885,214 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Silverlight program error Pin
Richard MacCutchan16-Nov-09 0:36
mveRichard MacCutchan16-Nov-09 0:36 
QuestionAdding a TabItem to an existing derived TabControl in WPF Pin
Richard Dutton15-Nov-09 23:39
Richard Dutton15-Nov-09 23:39 
AnswerRe: Adding a TabItem to an existing derived TabControl in WPF Pin
Mark Salsbery16-Nov-09 7:40
Mark Salsbery16-Nov-09 7:40 
GeneralRe: Adding a TabItem to an existing derived TabControl in WPF Pin
Richard Dutton16-Nov-09 21:25
Richard Dutton16-Nov-09 21:25 
GeneralRe: Adding a TabItem to an existing derived TabControl in WPF Pin
Mark Salsbery17-Nov-09 12:17
Mark Salsbery17-Nov-09 12:17 
QuestionWCF Pin
sris 42615-Nov-09 23:23
sris 42615-Nov-09 23:23 
AnswerRe: WCF Pin
Kevin McFarlane16-Nov-09 7:29
Kevin McFarlane16-Nov-09 7:29 
QuestionEquivalent binding in code? Pin
Richard Dutton15-Nov-09 22:58
Richard Dutton15-Nov-09 22:58 
Hi,

I'm in the process of refactoring some code I've inherited and as a part of this I need to re-create a binding which was previously in my WPF in code. The WPF snippet is:

<pre><TabItem Header="Notes">
<my:HelpEditor PlantId="{Binding Path=Id, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type my:Symbol}}}">
</TabItem></pre>

But I am now producing these TabItems in code so need to reproduce this binding in my code-behind file. In this case HelpEditor is a custom UserControl with a PlantId dependency property and Symbol is a custom object with a Id dependency property. HelpEditor needs to be bound to the Id in Symbol and so this WPF binding code works fine.

Here is the code I am trying to use in my code-behind file:

<pre>TabItem ti = new TabItem();
ti.Header = "Notes";
helpEditor = new ScadaAlarmViewer.HelpEditor();
Binding idBinding = new Binding("Id");
idBinding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MyStuff.Symbol), 1);
helpEditor.SetBinding(MyStuff.HelpEditor.PlantIdProperty, idBinding);
ti.Content = helpEditor;</pre>

But this doesn't work, I get:

<pre>System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='MyStuff.Symbol', AncestorLevel='1''. BindingExpression:Path=Id; DataItem=null; target element is 'HelpEditor' (Name=''); target property is 'PlantId' (type 'String')</pre>

In the output window. If it's relevant, these TabItems are contained withint a Popup.

Can anyone help?

Rich
AnswerRe: Equivalent binding in code? Pin
Gideon Engelberth16-Nov-09 4:56
Gideon Engelberth16-Nov-09 4:56 
QuestionHow to down the Excel file from Application folder in WPF with C# Pin
ChandrakanthGaddam15-Nov-09 20:03
ChandrakanthGaddam15-Nov-09 20:03 
AnswerRe: How to down the Excel file from Application folder in WPF with C# Pin
Christian Graus15-Nov-09 20:52
protectorChristian Graus15-Nov-09 20:52 
GeneralRe: How to down the Excel file from Application folder in WPF with C# Pin
ChandrakanthGaddam15-Nov-09 23:56
ChandrakanthGaddam15-Nov-09 23:56 
QuestionSilverLight Server ? Pin
Mohammad Dayyan15-Nov-09 0:21
Mohammad Dayyan15-Nov-09 0:21 
AnswerRe: SilverLight Server ? Pin
Mark Salsbery15-Nov-09 5:54
Mark Salsbery15-Nov-09 5:54 
QuestionMenu in WPF ? Pin
Mohammad Dayyan14-Nov-09 0:55
Mohammad Dayyan14-Nov-09 0:55 
AnswerRe: Menu in WPF ? Pin
Richard MacCutchan14-Nov-09 1:21
mveRichard MacCutchan14-Nov-09 1:21 
GeneralRe: Menu in WPF ? Pin
Mohammad Dayyan14-Nov-09 1:38
Mohammad Dayyan14-Nov-09 1:38 
GeneralRe: Menu in WPF ? Pin
Richard MacCutchan14-Nov-09 2:12
mveRichard MacCutchan14-Nov-09 2:12 
GeneralRe: Menu in WPF ? Pin
Christian Graus15-Nov-09 19:45
protectorChristian Graus15-Nov-09 19:45 
GeneralRe: Menu in WPF ? Pin
Mohammad Dayyan15-Nov-09 23:44
Mohammad Dayyan15-Nov-09 23:44 
AnswerRe: Menu in WPF ? Pin
Mark Salsbery14-Nov-09 10:34
Mark Salsbery14-Nov-09 10:34 
QuestionSkinnable silverlight applications Pin
Eduard Keilholz13-Nov-09 11:54
Eduard Keilholz13-Nov-09 11:54 
AnswerRe: Skinnable silverlight applications Pin
Mark Salsbery15-Nov-09 6:03
Mark Salsbery15-Nov-09 6:03 
GeneralRe: Skinnable silverlight applications Pin
Eduard Keilholz15-Nov-09 10:36
Eduard Keilholz15-Nov-09 10:36 
Questionrequest error Pin
Tauseef A13-Nov-09 7:17
Tauseef A13-Nov-09 7:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.