Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Window x:Class="ToolBarBindingTest.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:tb="..."
- Title="MainWindow" Height="350" Width="525">
- <StackPanel>
- <!-- This works as expected - when I type into the text box, the text appears
- in the tool bar. -->
- <TextBox Name="text"/>
- <ToolBarTray>
- <ToolBar>
- <TextBlock Text="{Binding Text, ElementName=text}"></TextBlock>
- </ToolBar>
- </ToolBarTray>
- <!-- This doesn't work. The only difference I can is that the regular ToolBar is
- ItemsControl and therefore uses ItemsCollection as its collection, where my
- tb:ToolBar uses FreezableCollection<tb:TooBarControl>. For reasons I'm not really
- going to detail (because it is irrelevant), I need strongly typed collection.
- A binding error is produced:
- System.Windows.Data Error: 4 : Cannot find source for binding with reference
- 'ElementName=text2'. BindingExpression:Path=Text; DataItem=null; target element
- is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
- -->
- <TextBox Name="text2"/>
- <tb:ToolBar>
- <tb:ToolBarControl>
- <TextBlock Text="{Binding Text, ElementName=text2}"></TextBlock>
- </tb:ToolBarControl>
- </tb:ToolBar>
- </StackPanel>
- </Window>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement