user220583
user220583

Reputation:

How to display a link in the pivotviewer detail pane

I'm using Silverlight 5's new pivotviewer and I am unable to get the hyperlinked title in the details pane.

 <sdk:PivotViewer Name="pivotView">
    <sdk:PivotViewer.PivotProperties>
        <sdk:PivotViewerStringProperty Id="TitleProperty" DisplayName="Title" Options="CanSearchText" Binding="{Binding Title}" />
        <sdk:PivotViewerDateTimeProperty Id="YearProperty" DisplayName="Year" Options="CanFilter" Binding="{Binding Year}"/>
        <sdk:PivotViewerStringProperty Id="TypeProperty" DisplayName="Type" Options="CanFilter" Binding="{Binding Type}"/>
        <sdk:PivotViewerNumericProperty Id="AvgProperty" DisplayName="Average" Options="CanFilter" Binding="{Binding Avg}"/>
        <sdk:PivotViewerNumericProperty Id="RankProperty" DisplayName="Rank" Options="CanFilter" Binding="{Binding Rank}"/>
        <sdk:PivotViewerNumericProperty Id="EpisodeProperty" DisplayName="Episodes" Options="CanFilter" Binding="{Binding EpisodeCount}"/>
        <sdk:PivotViewerLinkProperty Id="UriProperty" DisplayName="Location"  Binding="{Binding Title}"/>
    </sdk:PivotViewer.PivotProperties>
    <sdk:PivotViewer.ItemTemplates>
        <sdk:PivotViewerItemTemplate>
            <Border Width="200" Height="200" Background="Gray">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Title}"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </sdk:PivotViewerItemTemplate>
    </sdk:PivotViewer.ItemTemplates>
</sdk:PivotViewer>

Upvotes: 0

Views: 1064

Answers (2)

doza
doza

Reputation: 1561

I had an issue where the entire collection failed to display, since I was binding a PivotViewerLinkProperty to a string field, rather than a field of type PivotViewerHyperlink.

To avoid changing my service definition, I added a Converter (registered in my App.xaml):

public class DBURLConverter : IValueConverter
{
    public object Convert(object value
        , Type targetType
        , object parameter
        , CultureInfo culture)
    {
        return new PivotViewerHyperlink("URL Title", new Uri(value.ToString()));
    }

    public object ConvertBack(object value
        , Type targetType
        , object parameter
        , CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

and then used the converter while binding to the original URL string field:

 <pivot:PivotViewerLinkProperty      
         Id="My URL"    Options="None"
         Binding="{Binding MyURL, Converter={StaticResource DBURLConverter}}" /> 

To answer your specific point about displaying in the Details pane, Options="None" was sufficient to make it appear in the details pane, but not as a filter etc.

Upvotes: 0

IrishBoiler
IrishBoiler

Reputation: 55

I don't see the Options attribute set for the link property like the others.

To only show it in the details pane, you need to set Options=Private

<sdk:PivotViewerLinkProperty Id="UriProperty" DisplayName="Location" Options="Private"  Binding="{Binding Title}"/>

MSDN PivotViewerPropertyOptions Enum

Upvotes: 0

Related Questions