Determining SlideView's control size before images loaded

4 posts, 0 answers
  1. Pooja
    Pooja avatar
    5 posts
    Member since:
    Sep 2013

    Posted 22 Sep 2014 Link to this post

    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











  2. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    551 posts

    Posted 25 Sep 2014 Link to this post

    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.

     
  3. DevCraft banner
  4. Pooja
    Pooja avatar
    5 posts
    Member since:
    Sep 2013

    Posted 25 Sep 2014 Link to this post

    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
     
  5. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    551 posts

    Posted 30 Sep 2014 Link to this post

    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.

     
Back to Top