Note that there are some explanatory texts on larger screens.

plurals
  1. POXAML Tool Tip Data Context and Multi Binding
    primarykey
    data
    text
    <p>I have a ListView in my XAML and I am trying to hook up a MultiBinding Converter. </p> <pre><code>&lt;ListView Grid.Column="4" Grid.Row="1" Grid.RowSpan="5" Margin="8,0,8,8" HorizontalAlignment="Stretch" Name="lvDisplayType" ItemsSource="{Binding Path=Types}" SelectedItem="{Binding Path=Current.Opt}" VerticalAlignment="Stretch" SelectionChanged="lvType_SelectionChanged" SelectionMode="Single" ScrollViewer.HorizontalScrollBarVisibility="Disabled"&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;DockPanel HorizontalAlignment="Center"&gt; &lt;TextBlock Text="{Binding Path=., Converter={StaticResource DisplayConverter}}" HorizontalAlignment="Center" Padding="6" VerticalAlignment="Center" TextWrapping="Wrap"&gt; &lt;TextBlock.ToolTip&gt; &lt;ToolTip DataContext="{Binding Path=Current}"&gt; &lt;MultiBinding Converter="{StaticResource OptConverter}"&gt; &lt;Binding Path="Opt" /&gt; &lt;Binding Path="Type" /&gt; &lt;/MultiBinding&gt; &lt;/ToolTip&gt; &lt;/TextBlock.ToolTip&gt; &lt;/TextBlock&gt; &lt;/DockPanel&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; </code></pre> <p>The code not working is:</p> <pre><code> &lt;TextBlock.ToolTip&gt; &lt;ToolTip DataContext="{Binding Path=Current}"&gt; &lt;MultiBinding Converter="{StaticResource OptConverter}"&gt; &lt;Binding Path="Opt" /&gt; &lt;Binding Path="Type" /&gt; &lt;/MultiBinding&gt; &lt;/ToolTip&gt; &lt;/TextBlock.ToolTip&gt; </code></pre> <p>At present the Converter is returning an empty string as both 'values[0] == System.Windows.DependencyProperty.UnsetValue' and 'values[1] == System.Windows.DependencyProperty.UnsetValue' return true. These values are never set.</p> <p>Because of the logical tree (I think) the TextBlock.ToolTip default binding is 'Current.Opt'. For the MultiBinding I also need to refer to 'Type' which is another property of 'Current'. So to get around this I have set 'ToolTip DataContext="{Binding Path=Current}"' - this isn't working as expected - what am I doing wrong?</p> <p>I know I could do this easily in the Code behind, but we are employing MVVM, so would like to avoid it if possible.</p> <p>Any help greatly appreciated!</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload