מדריך Silverlight – פקדים בסיסיים
Silverlight מכילה מספר רב של פקדים מוכנים מהקופסא. בפרקים הבאים נדבר על הפקדים הבסיסיים המסופקים. פקדים אלו הם יחידות הבסיס לכל אתר ועל כן חשובה מאוד הכרות טובה עימם.
בפרקים הבאים נצלול לעומק הפקדים ולמד לגבי כל פקד על התכונות החשובות שלו.
עם זאת ישנם מספר תכונות חשובות אשר משותפות לכלל הפקדים ונלמד אותם בפרק זה.
התכונה Visibility
התכונה Visibility מאפשרת להציג פקד (זוהי ברירת המחדל, Visiblity.Visible) או לקפל את הפקד (Visibility.Collapsed). במצב מקופל הפקד אינו טופס מקום ואינו נראה.
בדוגמא הבאה ניתן לראות שהכפתור השני מופיע בראש העמוד מאחר והכפתור שהיה לפניו נמצא במצב מקופל:
<UserControl x:Class="FirstSilverlightApplication3.MainPage"
>="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>:x="http://schemas.microsoft.com/winfx/2006/xaml"
>:d="http://schemas.microsoft.com/expression/blend/2008"
>:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<StackPanel>
<Button Content="Collapsed button"
Visibility="Collapsed" />
<Button Content="Visible button"
Visibility="Visible" />
</StackPanel>
</UserControl>
התכונה IsEnabled
התכונה IsEnabled מאפשרת לקבוע האם הפקד פעיל או לא. פקד שאינו פעיל לא ניתן ללחוץ עליו או להשתמש בו. לרוב פקד שאינו פעיל גם מצויר אחרת כדי להדגיש את העובדה שאינו פעיל.
<UserControl x:Class="FirstSilverlightApplication3.MainPage"
>="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>:x="http://schemas.microsoft.com/winfx/2006/xaml"
>:d="http://schemas.microsoft.com/expression/blend/2008"
>:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<StackPanel>
<Button Content="Enabled button"
IsEnabled="True" />
<Button Content="Disabled button"
IsEnabled="False" />
</StackPanel>
</UserControl>
מה נלמד בפרקים הבאים?
- נלמד על הסוגים השונים של פקדי כפתורים
- נלמד על הסוגים השונים של פקדי טקסט
- נלמד על הפקד ListBox להצגת רשימת אלמנטים
- נלמד על הפקד ComboBox לבחירת אלמנט מתוך רשימה
תגובות בפייסבוק