views:

162

answers:

0

I'd like to show the PixelWidth & PixelHeight of the image (not thumbnail) in tooltip, But I have not idea how to do binding in the datetemplate,

I try to use "{Binding ElementName=imgPreview, Path=Source.PixelWidth}"/>, but got nothing.

Could anyone explain how to do it?

            <ListBox.ItemTemplate>
            <DataTemplate>
                <Border>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Image >
                           <Image.Source>
                                <PriorityBinding>
                                    <Binding Path="Thumbnail" IsAsync="True" />
                                </PriorityBinding>
                           </Image.Source>
                           <Image.ToolTip>
                                <ToolTip>
                                    <StackPanel>
                                        <Image Source="{Binding Path=ImageFilename}" x:Name="imgPreview"/>

                                    <!--Image Source's PixelWidth-->
                                    <!--Image Source's PixelHeight-->
                                    </StackPanel>
                                </ToolTip>
                            </Image.ToolTip>
                        </Image>
                        <TextBlock Grid.Row="1" Text="{Binding Path=Name}"
                                TextAlignment="Center" TextTrimming="CharacterEllipsis"
                                HorizontalAlignment="Stretch">
                        </TextBlock>
                    </Grid>
                </Border>
            </DataTemplate>
        </ListBox.ItemTemplate>