Skip to content

Instantly share code, notes, and snippets.

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
<ListView>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
// Some data to work with
List<string> countries = {"Argentina", "Australia", "Belgium", "Chile", "Denmark", "Fiji", "Germany", "Greece"};
// Using a foreach loop
var filteredList = new List<string>();
foreach(var c in countries)
{
if (c.Contains("e"))
{
filteredList.Add(c);
// Some data to work with
List<string> countries = {"Argentina", "Australia", "Belgium", "Chile", "Denmark", "Fiji", "Germany", "Greece"};
// Using a foreach loop
var newList = new List<string>();
foreach(var c in countries)
{
if (c.Contains("e"))
{
newList.Add(c);
x => /*some code goes here*/
List<string> countries = {"Argentina", "Australia", "Belgium", "Chile", "Denmark", "Fiji", "Germany", "Greece"};
var newList = from c in countries
where c.Contains("e")
select c.ToUpper();