Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Binding inside binding question

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 12-03-2007   #1 (permalink)
Yoavo
Guest


 

Binding inside binding question

Hi,
I want to bind Text property of TextBox to a dictionary where key is a name of the TextBox. (I want to make a Style out of that and use it for a number of TextBoxes).

The binding does not work. (exception in debugger).
Can someone please advise ?



Here is my Xaml:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:LableList="clr-namespace:LableList"
x:Class="LableList.Window1"
x:Name="Window"
Title="Window1"
Loaded="WindowLoaded"
Width="640" Height="480">

<Grid x:Name="LayoutRoot">
<TextBox x:Name="QType">
<TextBox.Text>
<Binding Source="{x:Static Application.Current}"
Path="MainWindow.DataMap[{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Name}].Data"/>
</TextBox.Text>
</TextBox>
</Grid>
</Window>



And here is the c# code:
namespace LableList
{
public partial class Window1
{
private Dictionary<string, Value> _DataMap = new Dictionary<string,Value>();
public Dictionary<string, Value> DataMap
{
get { return _DataMap; }
}
public Window1()
{
DataMap.Add("QType", new Value("QType", "aaaaa"));
this.InitializeComponent();
}
}

public class Value
{
public Value(string iName, string iData)
{
_Name = iName;
_Data = iData;
}
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}

private string _Data;
public string Data
{
get { return _Data; }
set { _Data = value; }
}

public override string ToString()
{
return Data;
}
}
}



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding to a Foreign Key Binding? -=B3N=- Avalon 0 06-14-2007 06:45 AM
Binding Question (Binding in General) Jason Avalon 2 05-09-2007 04:41 AM
WPF binding error when databinding a ComboBox inside a ListView it jeff.townes Avalon 0 05-01-2007 11:05 AM
Cmdlet Parameter Binding Question Keith Hill [MVP] PowerShell 13 12-10-2006 10:22 PM
Binding Question Bree Avalon 4 12-06-2006 09:08 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51