I am having issues with updating my DataTemplate for the list of "Movie" objects. Specifically I have an image within those objects which is being displayed in a looping list. The object in the center will have a larger image while the images further away will get smaller.
I am using C# and WPF.
In my Window.Resources:
<DataTemplate DataType="{x:Type src:Movie}">
<StackPanel Orientation="Vertical" Margin="0" Background="Transparent" Width="Auto" Name="MovieDataStack">
<Image Name="MovieImage" Margin="10,0,10,0" Source="{Binding ImagePath}" Width="{Binding Size}" Height="Auto" VerticalAlignment="Center" HorizontalAlignment="Center" />
</StackPanel>
</DataTemplate>
My Movie class contains a variable called Size which can be changed, but whenever I update the variable the template does not update.
I create a list of movies at the beginning of my program (in App.xaml.cs) and use the list in another xaml (TicketScreen.xaml) file:
<dw:LoopingListBox x:Name="movieScroller" Margin="81.683,65.013,66.149,43.342"
ItemsSource="{StaticResource Movies}"
开发者_运维问答 ItemContainerStyle="{StaticResource MovieContainerStyle}" Background="Transparent" MouseUp="movieScroller_MouseUp"/>
How do I update the images of each child in the looping list? I have a feeling the DataTemplate is used for all the movies, so I can't specify a different size for each movie.
Thanks so much for the help ^^
Is this MVVM ?
You should have a collection of Data called Movie
A collection of Movie called Movies.
Search threw your collection of Movies and change the property that corresponds to the Item number.
int TempIndex;
TempIndex = Movies.Count / 2;
TempMovie = Movies[TempIndex];
TempMovie.Width = 155;
TempMovie.Height = 155;
Theres probably a better way to do it, but this is how I've done it in the past. The syntax probably isnt perfect either
精彩评论