How to set the RelativeSource in a DataTemplate that is nested in a HierarchicalDataTemplate?

Posted by Dabblernl on Stack Overflow See other posts from Stack Overflow or by Dabblernl
Published on 2010-04-04T12:41:29Z Indexed on 2010/04/04 12:43 UTC
Read the original article Hit count: 320

Filed under:
|
|

I have the following XAML, that does all that it is supposed to, except that the MultiBinding on the FontSize fails on retrieving the Users. As you can see Users is an IEnumerable<UserData> that is part of the HierarchicalDataTemplate's DataContext.

How do I reference it??

<TreeView Name="AllGroups" ItemsSource="{Binding}" >
      <TreeView.Resources>
           <HierarchicalDataTemplate DataType="{x:Type PrivateMessengerUI:GroupContainer}"
                                     ItemsSource="{Binding Users}"
                                                  >
                  <Label Content="{Binding GroupName}"/>
            </HierarchicalDataTemplate>
            <DataTemplate DataType="{x:Type PrivateMessenger:UserData}">
               <TextBlock Text="{Binding Username}"
                          ToolTip="{StaticResource UserDataGroupBox}"
                          Name="GroupedUser"
                          MouseDown="GroupedUser_MouseDown">
                    <TextBlock.FontSize>
                         <MultiBinding Converter="{StaticResource LargeWhenIAmSelected}">
                               <Binding ElementName="Root" Path="SelectedUser"/>
                               <Binding RelativeSource="???"
                                        Path="DataContext.Users"/>
                         </MultiBinding>
                     </TextBlock.FontSize>
               </TextBlock>
           </DataTemplate>
         </TreeView.Resources>
      </TreeView>

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wpf