我正在写 Windows Phone 8 应用程序,它必须加载一个 EPG 列表。为此,我使用了一个列表框和一个数据模板。
<DataTemplate x:Key="FooDataTemplate">
<Button Margin="0,10,0,0" Style="{Binding Source={StaticResource ButtonNoMarginStyle}}" BorderThickness="0" Width="375" Height="105" Command="{Binding ElementName=pageRoot,Path=ViewModel.NavigateToDetailsCommand}" CommandParameter="{Binding Id}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition Width="195"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<controls:ImageControl ImageUri="{Binding Image}" Grid.RowSpan="2" Grid.Column="0" />
<Image Grid.RowSpan="2" Source="{StaticResource SecondCaptionImage}" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Right" Stretch="None"/>
<Grid Grid.Row="1" Visibility="{Binding IsCurrentEpg, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Rectangle Fill="#cc3e567b" Grid.ColumnSpan="4"/>
<TextBlock Text="DIRECT" FontSize="12" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Duration}" FontSize="12" Grid.Column="2" VerticalAlignment="Center"/>
</Grid>
</Grid>
<Grid Grid.Column="1" VerticalAlignment="Top" Margin="10,-8,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<!--Title-->
<RowDefinition Height="auto"/>
<!--SubTitle-->
<RowDefinition Height="auto"/>
<!--Hours-->
<RowDefinition Height="auto"/>
<!--Progress bar if needed-->
</Grid.RowDefinitions>
<TextBlock TextTrimming="WordEllipsis" Text="{Binding Title, Converter={StaticResource CaseStringConverter}, ConverterParameter=Upper}"/>
<TextBlock Grid.Row="1" TextTrimming="WordEllipsis" Text="{Binding Subtitle, Converter={StaticResource CaseStringConverter}, ConverterParameter=Upper}"/>
<TextBlock Grid.Row="2" Text="{Binding DurationTitle}"/>
<Grid Margin="-4,0,0,0" Grid.Row="3" Visibility="{Binding IsCurrentEpg, Converter={StaticResource BooleanToVisibilityConverter}}" >
<controls:EpgProgressBar Visibility="{Binding IsCurrentEpg, Converter={StaticResource BooleanToVisibilityConverter}}" Loaded="SecondProgressBarLoaded" IsEnabled="{Binding IsCurrentEpg}" CurrentEpg="{Binding}" Width="375" HorizontalAlignment="Left" />
</Grid>
</Grid>
</Grid>
</Button>
</DataTemplate>
如您所见,我使用了一个 EpgProgressBar,并且仅当它是当前 epg 时才显示它。视图设置正确,我只得到当前 epg 的进度条。但是,我可以在输出中看到每个按钮都有一个进度条。
如果该控件被折叠或隐藏,有没有办法不加载自定义控件(在我的情况下是进度条)?
问候。