This is a migrated thread and some comments may be shown as answers.

Determining SlideView's control size before images loaded

3 Answers 100 Views
SlideView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pooja
Top achievements
Rank 1
Pooja asked on 22 Sep 2014, 06:27 PM
Hello,

I have a SlideView with the structure as:

            <telerikPrimitives:RadSlideView x:Name="radSlideView" ItemsSource="{Binding}" 
                                            Loaded="RadSlideView_Loaded">
                <telerikPrimitives:RadSlideView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Image x:Name="imgMain" Source="{Binding Image}" Stretch="Uniform"/>
                            <StackPanel x:Name="stackCurrentStatus" Grid.Row="1" Orientation="Horizontal"
                                        HorizontalAlignment="Right" Margin="0,0,0,5">
                                <TextBlock Text="Album: " FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
                                <TextBlock Text="{Binding AlbumName}"/>
                                <Ellipse Width="6" Height="6" Fill="#3bb23b" Margin="6,0,6,0" VerticalAlignment="Center"/>
                                <TextBlock Text="{Binding PicIndexInAlbum}"/>
                                <TextBlock Text=" of "/>
                                <TextBlock Text="{Binding TotalPicsInAlbum}"/>                                
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </telerikPrimitives:RadSlideView.ItemTemplate>
            </telerikPrimitives:RadSlideView>

My requirement is that I need to show images inside RadSlideView without any blurred effect. For that, I have to resize my images (if required). Say, if my image's dimensions are larger than the dimensions of Image control declared inside RadSlideView, I need to resize the original image.

For resizing, i need the target/new dimensions. I can get the actual rendered dimension of my ImageView inside "SelectionChanged" event but I need this dimension before I use:
this.slideView..ItemsSource = List<Object>;

For this, i tried using Loaded event of RadSlideView like shown below but unable to get the access to Image control.
  private void RadSlideView_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                RadSlideView slideView = sender as RadSlideView;                
                if (slideView != null)
                {                    
                    Image imgObj = ElementTreeHelper.FindVisualDescendant<Image>(radSlideView.SelectedItemContainer);
                    if (imgObj != null)
                    {
///do code here
}
}}}

In above code, the object imgObj is coming out to be Null.

Can you please let me know how can i know in advance (before actual rendering) the dimensions of the Image control in RadSlideView?

Thanks,
Pooja Arora











3 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 25 Sep 2014, 02:53 PM
Hi Pooja,

Thank you for contacting us.

You can get the actual size of an image after it has been opened. For that you can use the Image.ImageOpened event. I have attached a sample application for demonstration.

I hope this helps.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Pooja
Top achievements
Rank 1
answered on 25 Sep 2014, 04:23 PM
Hi Rosy,

Thanks for replying.

This is not what I was looking for. I need to know the dimensions of the Slide view itself in which images has to be rendered.

My scenario is I am picking all images from device and show them in slide view. Some of the images which are larger/smaller than the size of slide view are getting tampered either looking squeezed or enlarged a lot. So, before I write

this.radSlideView.ItemsSource = List<MyClass>;

I need to know the exact dimensions of slide view so that i can resize my images accordingly.

Tried to make it clear. Hope its understandable.

Thanks
 
0
Rosy Topchiyska
Telerik team
answered on 30 Sep 2014, 11:25 AM
Hi Pooja,

Sorry for the misunderstanding. I have attached a sample project that demonstrates how you can get the size of the Image control and also the available space that it could take.

I hope this helps.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
SlideView
Asked by
Pooja
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Pooja
Top achievements
Rank 1
Share this question
or