1
Vote

PlaceHolder doesn't work when EmptyPlaceholderTemplate is defined

description

Hi all,

PlaceHolder doesn't work when EmptyPlaceholderTemplate has been defined.

EmptyPlaceholderTemplate sample:
<ctrl:ListPlaceholder ListTarget="{Binding ElementName=lstCheckList}"
       LoadingPlaceholderContent="{Binding LoadingData, Source={StaticResource LocalizedStrings}}" >
    <ctrl:ListPlaceholder.EmptyPlaceholderTemplate>
        <DataTemplate >
            <StackPanel Orientation="Vertical">
                <TextBlock Text="No items found !" Style="{ThemeResource ListViewEmptyStaticTextBlockStyle}" />
                <HyperlinkButton Margin="0,10,0,0" VerticalAlignment="Top"
                    Content="Add a new one..."
                    Command="{Binding CheckListItemClickCommad}"
                    Foreground="{ThemeResource PhoneAccentBrush}"/>
            </StackPanel>
        </DataTemplate>
    </ctrl:ListPlaceholder.EmptyPlaceholderTemplate>
</ctrl:ListPlaceholder>

<ListView x:Name="lstCheckList"  />
Solution:
In code, (in class ListPlaceholder), we have to change method "PresentEmptyPlaceholder" like show bellow:
private void PresentEmptyPlaceholder()
{
    // Updated 16/09/2015: Juan Luis Guerrero. U
    // Use PlaceholderContent only when no PlaceholderTemplate has been defined or It's a Textblock.
    // If It's a TextBlock, no User interaction will be required.
    if (null == EmptyPlaceholderTemplate || EmptyPlaceholderTemplate.LoadContent() is TextBlock)
    {
        // PlaceholderTemplate = EmptyPlaceholderTemplate;
        PlaceholderContent = EmptyPlaceholderContent;
    }

    PlaceholderTemplate = EmptyPlaceholderTemplate;
    PlaceholderVisibility = Visibility.Visible;
}
Hope this help !
Regards
Juanlu, ElGuerre

comments