You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wpf/Accordion/Selecting-Items.md
+147Lines changed: 147 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,157 @@ Items can be selected programmatically using the properties [SelectedIndex](http
15
15
16
16
[SelectedIndex](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Layout.SfAccordion.html#Syncfusion_Windows_Controls_Layout_SfAccordion_SelectedIndex) property is used to select an item using its index. It contains the index of most recently selected item in case of OneOrMore, ZeroOrMore SelectionModes.
Content="WPF is a framework for building rich Windows desktop applications"/>
24
+
<layout:SfAccordionItem Header="UWP"
25
+
Content="UWP is a framework for building cross-platform Windows applications."/>
26
+
<layout:SfAccordionItem Header="WinUI"
27
+
Content="WinUI is a modern framework for building Windows desktop applications."/>
28
+
<layout:SfAccordionItem Header="Windows Forms"
29
+
Content="Windows Forms is a UI framework for building classic Windows desktop applications."/>
30
+
<layout:SfAccordionItem Header="Metro Studio"
31
+
Content="Metro Studio is an icon library with customizable flat and wireframe icon templates."/>
32
+
</layout:SfAccordion>
33
+
{% endhighlight %}
34
+
35
+
{% highlight C# %}
36
+
37
+
// Create SfAccordion control
38
+
SfAccordion accordion = new SfAccordion();
39
+
accordion.Width = 500;
40
+
accordion.Height = 200;
41
+
42
+
// Create SfAccordionItems
43
+
SfAccordionItem wpfItem = new SfAccordionItem
44
+
{
45
+
Header = "WPF",
46
+
Content = "WPF is a framework for building rich Windows desktop applications"
47
+
};
48
+
SfAccordionItem uWPItem = new SfAccordionItem
49
+
{
50
+
Header = "UWP",
51
+
Content = "UWP is a framework for building cross-platform Windows applications."
52
+
};
53
+
54
+
SfAccordionItem winUIItem = new SfAccordionItem
55
+
{
56
+
Header = "WinUI",
57
+
Content = "WinUI is a modern framework for building Windows desktop applications."
58
+
};
59
+
60
+
SfAccordionItem windowsFormsItem = new SfAccordionItem
61
+
{
62
+
Header = "Windows Forms",
63
+
Content = "Windows Forms is a UI framework for building classic Windows desktop applications."
64
+
};
65
+
66
+
SfAccordionItem metroStudioItem = new SfAccordionItem
67
+
{
68
+
Header = "Metro Studio",
69
+
Content = "Metro Studio is an icon library with customizable flat and wireframe icon templates."
70
+
};
71
+
72
+
// Add the items to the accordion
73
+
accordion.Items.Add(wpfItem);
74
+
accordion.Items.Add(uWPItem);
75
+
accordion.Items.Add(winUIItem);
76
+
accordion.Items.Add(windowsFormsItem);
77
+
accordion.Items.Add(metroStudioItem);
78
+
accordion.SelectedIndex = 2;
79
+
80
+
{% endhighlight %}
81
+
82
+
{% endtabs %}
83
+
84
+

85
+
18
86
## Selecting item using SelectedItem
19
87
20
88
[SelectedItem](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Layout.SfAccordion.html#Syncfusion_Windows_Controls_Layout_SfAccordion_SelectedItem) property is used to select an item using its instance. It contains the instance of most recently selected item in case of OneOrMore, ZeroOrMore SelectionModes.
new AccordionItem { Name = "WPF", Description = "WPF is a framework for building rich Windows desktop applications."},
147
+
new AccordionItem { Name = "UWP", Description = "UWP is a framework for building cross-platform Windows applications." },
148
+
new AccordionItem { Name = "WinUI", Description = "WinUI is a modern framework for building Windows desktop applications." },
149
+
new AccordionItem { Name = "Windows Form", Description = "Windows Forms is a UI framework for building classic Windows desktop applications." },
150
+
new AccordionItem { Name = "Metro Studio", Description = "Metro Studio is an icon library with customizable flat and wireframe icon templates." }
151
+
};
152
+
153
+
SelectedItem = Items[4];
154
+
}
155
+
}
156
+
157
+
public class AccordionItem
158
+
{
159
+
public string Name { get; set; }
160
+
public string Description { get; set; }
161
+
}
162
+
163
+
{% endhighlight %}
164
+
165
+
{% endtabs %}
166
+
167
+

168
+
22
169
## Retrieving the selected items
23
170
24
171
[SelectedItems](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Layout.SfAccordion.html#Syncfusion_Windows_Controls_Layout_SfAccordion_SelectedItems) property contains a collection of selected items instances for all the SelectionModes. It is a read only property and it cannot be set.
0 commit comments