我正在寫的Windows Phone 8應用程序,它必須加載一個epgs列表。 爲此,我使用了一個列表框和一個數據模板。不加載自定義控件,如果它被摺疊
<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的進度條。但是,我可以在輸出中看到每個按鈕都有一個進度條。
如果此控件被摺疊或隱藏,有沒有辦法加載自定義控件(在我的情況下是進度條)?
問候。
只是爲了澄清,是「EPG」一個http://en.wikipedia.org/wiki/Electronic_program_guide? – quetzalcoatl 2013-03-07 10:34:22
是的,它是一個電視節目的清單。 – David 2013-03-07 10:35:27