Reputation: 6235
I tried to use the control from this post - FlipView Control. Here is what I have:
<flipViewControl:FlipView ItemsSource="{Binding Images}" Name="ImagesFlipView"
SelectedIndex="{Binding ElementName=ProductImagesBullets, Path=SelectedIndex, Mode=TwoWay}" Grid.Row="0">
<flipViewControl:FlipView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding FileLocation, Converter={StaticResource ImagePathConverter}}" Stretch="Fill"/>
</DataTemplate>
</flipViewControl:FlipView.ItemTemplate>
</flipViewControl:FlipView>
ImagePathConverter
set ImageSource:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var url = string.Format("{0}{1}", ConfigurationManager.AppSettings["SiteUri"], value);
var bi = new BitmapImage();
bi.BeginInit();
bi.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
bi.CacheOption = BitmapCacheOption.OnDemand;
bi.UriSource = new Uri(url);
bi.EndInit();
return bi.Clone();
}
But in this user control, in Debug, I never get inside this converter (When I tried it on a simple alone image, it works).
What can be the solution for this problem? (Images aren't displayed, because converter doesn't apply correct ImageSource for Image)
I have created a test project with this control and converter - it works... Strange, very strange
UPD : Now it seems like
<flipViewControl:FlipView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FileLocation}"></TextBlock>
<!--<Image Source="{Binding FileLocation, Converter={StaticResource ImagePathConverter}}" Stretch="Fill"/>-->
</DataTemplate>
</flipViewControl:FlipView.ItemTemplate>
doesn't work at all. I have tried to set another template, but it also doesn't work. About binding - I have added the Converter just to see what is bound like here and Binding is correct.
UPD : Problem resolved when I understand that Custom Control should be as separate dll
. So I just move my code into separate project and add reference to Main project...
Upvotes: 1
Views: 114
Reputation: 1261
What about changing the property FileLocation to something like
public object FileLocation
{
get
{
try
{
return new BitmapImage(new Uri((string)PathToImage));
}
catch
{
return new BitmapImage();
}
}
}
XAML
<flipViewControl:FlipView ItemsSource="{Binding Images}" Name="ImagesFlipView" SelectedIndex="{Binding ElementName=ProductImagesBullets, Path=SelectedIndex, Mode=TwoWay}" Grid.Row="0">
<flipViewControl:FlipView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding FileLocation}" />
</DataTemplate>
</flipViewControl:FlipView.ItemTemplate>
</flipViewControl:FlipView>
without using a Converter?
Upvotes: 0