I have created a WPF Browser Application in which I have added a list box which displays Font Names. And I have used a User Control which contains a text box.
I want that after running application, when user selects the item from list box, it's selected item should be displayed in the text box of User Control.
I have written below code and added user control to main page but when I am selecting item, nothing is appearing in the text box of user control.
The main page and user control are in same assembly
Can any one advice what wrong I am doing ?
Thanks and Regards
Prasad
Main Page code :
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfBApp"
Title="Page2" Loaded="Page_Loaded">
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
/>
User Control Code :
<UserControl x:Class="WpfBApp.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<TextBox Height="23" Margin="84,52,96,0" x:Name="textBox1"
VerticalAlignment="Top"
Text='{Binding ElementName=MyNumbers,Path=SelectedItem.Content}'/>
UserControl>
Martin CookPosted Feb 10, 2010, 6:39 AM
You're user controls data context has already been set so you don't need to specify it again. Something like this should work: -
<TextBox Height="23" Margin="84,52,96,0" x:Name="textBox1"
VerticalAlignment="Top"
Text='{Binding Path=Content}'/>
Cheers,
Martin