Ugrás a tartalomhoz

.NET Programming Technologies

Gergely Kovásznai, Csaba Biró

Eszterházy Károly College

Other controls

Other controls

Controls in this group do not have any Content features. Specially suited for a specific task, such as Image control for displaying images, or the TextBlock control for texts.


Control for entering and displaying texts. TextBox can be created by the following syntaxes:

<TextBox />

<TextBox Text="TextBox!"/>


If you only want to use it for displaying texts, the value of the IsReadOnly feature has to be ”True”.

<TextBox IsReadOnly="True" Text="Read only text!"/>

If you would like to the text clicking automatically, set for Wrap the TextWrapping feature.

<TextBox TextWrapping="Wrap" Text=" Wrapping text " Height="40"/>

The ScrollBar can be visible with using Visible value of the VerticalScrollBarVisibility feature.

<TextBox VerticalScrollBarVisibility="Visible" TextWrapping="Wrap" Text="Wrapping text" Height="100"/>


The TextBox control is used for displaying a relatively small amount of texts or even formatted content can be done by the following syntaxes, which does not support hot keys.




<TextBlock Text="TextBlock" TextWrapping="Wrap" Width="40"/>


Image control is used for displaying images. The most important feature is the Source. Using this feature it is possible to attribute the file location with Uniform Resource Identifier (URI) and relative reference.

<Image Source="C:\Kepek\Föld.jpg" />

<Image Source="Föld.jpg" Width="100" Height="100" Stretch="Fill"/>

Strech property:

None – The image is displayed in its original size and cut the part of the image, which does not fit within the designated area.

Fill – Fills the selected area of the image passing over the original aspect ratios, so the picture may be distorted.

Uniform – Completes the selected area with the image, retention the aspect ratios (proportion)

UniformToFill – Fills completely the selected area with the image, retention the proportion.

V.6. Strech property


The MediaElement allows you to play various multimedia files supporting any types like Windows Media Player 10 do.

Example V.6. MediaPlayer

V.7. Media Player

<Grid x:Name="Player">

     <Border Margin="7" Background="Black" CornerRadius="10">

          <MediaElement x:Name="Media" Margin="10"

                     Volume="{Binding ElementName=slidVolume, Path=Value}"

                     Balance="{Binding ElementName=slidBalance, Path=Value}"







Open media:

        private void btnBrowse_Click(object sender, RoutedEventArgs e)


            OpenFileDialog dlg = new OpenFileDialog();

            Nullable<bool> result = dlg.ShowDialog();

            if (result == true)

                Media.Source = new Uri(dlg.FileName);


Paly media:

        private void btnPlay_Click(object sender, RoutedEventArgs e)





Pause media:

        private void btnPause_Click(object sender, RoutedEventArgs e)





The sliders allow you to enter a setting within a specified range of values.


IsDirectionReserved – the minimum value is assigned to the left side, the maximum one to the right side of the slider by default. If this feature is set to „True”,  the two sides will be swapped.

IsEnabled – allows to enable or disable the slider

LargeChange – you can adjust the step size for PageUp and PageDown keys

Maximum – the maximum value of the slider

Minimum – the minimum value of the slider

Orientation – the slider orientation can be adjusted

SmallChange – the increment can be adjusted for cursor keys

Value – Current value, which is always between the minimum and the maximum

Example V.7 Slider


    <Slider x:Name="slider1" Width="100" Value="50" Minimum="10" Maximum="100"/>

    <Image Source="C:\Pictures\Earth.jpg" Height="{Binding ElementName=slider1, Path=Value}"

             Width="{Binding ElementName=slider1, Path=Value}" />



We can find it as the element of the StatusBar. We will look at some examples for it later.


IsEnabled – allows you to enable or disable of the progress bar,

LargeChange – allows you to set large step,

Maximum – the maximum value of the progress bar,

Minimum – the minimum value of the progress bar ,

Orientation – used to help the orientation of the progress bar ,

SmallChange- allows you to set small step ,

Value - Current value, which is always between the minimum and the maximum.

Example V.8 ProgressBar

<ProgressBar x:Name="ProgressBar1" Width="200" Height="30"  Value="40"/>