Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Binding inside binding question

 
 
Old 12-03-2007   #1 (permalink)
Yoavo


 
 

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
 

Thread Tools


Similar Threads
Thread Forum
Cmdlet Parameter Binding Question PowerShell


Vista Forums 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 Ltd

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