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

How to display some text depending on if a file is selected

2 Answers 48 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Kirk Quinbar
Top achievements
Rank 1
Kirk Quinbar asked on 17 Dec 2010, 10:15 PM

In the attached image you will see how I want the second radupload control to look like. when no files are selected, i wanted to display some gray text ("optional" in this case), kinda like the EmptyContent that is on your maskededitcontrol. From what i can tell, I thought that I would do this in the style i can apply to the RadUpload control in the rootelement section as shown below. So i was just going to use a TextBlock right by the ItemsPresenter. The issue I have is i need to show or not show that textblock depending on if a file has been selected by the user. Is there something i could bind to the Visibility (thru a converter probably?) property of the textblock at this point in the style that would allow this? or is there a better way to accomplish what i want?

<Grid x:Name="RootElement" VerticalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Border 
                                    Grid.Column="0" 
                                    BorderThickness="1" 
                                    Background="#FFFFFFFF"
                                    Padding="2" 
                                    CornerRadius="2"
                                    VerticalAlignment="Top" 
                                    Height="24"
                                    MinWidth="300">
                                    <Grid VerticalAlignment="Top" HorizontalAlignment="Left">
                                        <TextBlock Text="optional" FontStyle="Italic" Foreground="Gray" />
                                        <ItemsPresenter VerticalAlignment="Top" HorizontalAlignment="Left"/>
                                    </Grid>
                                </Border>
                                <telerik:RadButton 
                                    x:Name="BrowseButton" 
                                    Grid.Column="1" 
                                    HorizontalAlignment="Left" 
                                    VerticalAlignment="Center" 
                                    Margin="-5,0,0,0"
                                    Content="{Binding ShellResource.BrowseButton, Source={StaticResource Localization}}" 
                                    Style="{StaticResource Button_Main}" />
                            </Grid>

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Fidanov
Telerik team
answered on 20 Dec 2010, 12:49 PM
Hi Kirk Quinbar,

The RadUpload is an ItemsControl (ListBox), so you can bind to its Items.Count property and display the empty content with a IValueConverter. The CaptionText is another option as when there are no files selected, it would be "Select Files To Upload", so you can bind to it as well.

Regards,
Alex Fidanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Kirk Quinbar
Top achievements
Rank 1
answered on 20 Dec 2010, 10:16 PM
Thanks! that works perfect. For anyone interested my code is below. I added a textblock right before the ItemsPresenter so i could show basically like a watermark in the radupload when nothing is selected. it just displays "optional" to my users.


<Grid x:Name="RootElement" VerticalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Border 
                                    Grid.Column="0" 
                                    BorderThickness="1" 
                                    Background="#FFFFFFFF"
                                    Padding="2" 
                                    CornerRadius="2"
                                    VerticalAlignment="Top" 
                                    Height="24"
                                    MinWidth="300">
                                    <Grid VerticalAlignment="Top" HorizontalAlignment="Left">
                                        <TextBlock Text="optional" Visibility="{Binding Items.Count, Converter={StaticResource CountToVisibility}, RelativeSource={RelativeSource Mode=TemplatedParent}}" FontStyle="Italic" Foreground="Gray" />
                                        <ItemsPresenter VerticalAlignment="Top" HorizontalAlignment="Left"/>
                                    </Grid>
                                </Border>
                                <telerik:RadButton 
                                    x:Name="BrowseButton" 
                                    Grid.Column="1" 
                                    HorizontalAlignment="Left" 
                                    VerticalAlignment="Center" 
                                    Margin="-5,0,0,0"
                                    Content="{Binding ShellResource.BrowseButton, Source={StaticResource Localization}}" 
                                    Style="{StaticResource Button_Main}" />
                            </Grid>
Tags
Upload
Asked by
Kirk Quinbar
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Kirk Quinbar
Top achievements
Rank 1
Share this question
or