The UserControl is composed of two labels and one Textbox.Some relative codes are below
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
DataContext = this;
}
public string Title { get; set; }
public string Company {get; set; }
public TextBox TrueText;
private void Input_Loaded(object sender, RoutedEventArgs e)
{
this.TrueText = sender as TextBox;
}
}
xaml
<Viewbox >
<Grid HorizontalAlignment="Left" VerticalAlignment="Center">
<Label Content="{Binding Title}" HorizontalAlignment="Left" Height="20" VerticalAlignment="Center" Padding="0,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="180"/>
<TextBox Margin="180,0,0,0" Name="Input" Loaded="Input_Loaded" Controls:TextBoxHelper.Watermark="待输入" Controls:TextBoxHelper.ClearTextButton="True" Padding="0,0,0,0" VerticalContentAlignment="Center" MinHeight="0" HorizontalAlignment="Left" VerticalAlignment="Center" Width="120" Height="18"/>
<Label Content="{Binding Company}" HorizontalAlignment="Left" Height="18" Margin="300,1,0,0" VerticalAlignment="Top" Width="50" Padding="0,0,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</Grid>
</Viewbox>
Then I want to get the Input in TextBox of each UserControl.But I can't get the children of the UniformGrid.
I have tried to use GetChildObject, but in this way I can't access his related properties
This is my wrong codeyour text
IEnumerable<UserControl1> list = (IEnumerable<UserControl1>)Grid1.GetChildObjects();
int i = 1;
double[] num = { 0 };
foreach (var u in list)
{
i++;
num[i] = Convert.ToDouble(u.TrueText.Text);
}
Any solution will be truly appreciated
Related
For my current projet i want to make an UI where information are displayed on "tile" which i designed as a Grid with other Label and progress bar into. But i can't figure out how to make those tiles displayed on my main grid.
I already tried Gridview that didn't work with the exemples on the web and making someway without grid isn't really easy.
This is the grid to insert as many times as needed
<Grid Margin="10" Background="AntiqueWhite" Grid.Row="0" Grid.Column="0">
<Label Content="{Binding fieldname}" FontFamily="Arial Black" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,20,0,0"/>
<Label Content="{Binding datebegin}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="85,85,0,0" FontFamily="Arial Black" FontSize="18" />
<Label Content="{Binding dateend}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="285,85,0,0" FontFamily="Arial Black" FontSize="18" />
<ProgressBar Margin="0,150,0,0" Value="{Binding progression}" Background="White" BorderBrush="Black" VerticalAlignment="Top" Height="50" />
</Grid>
I need a way to add the exact tile produced into a grid (or anything else that can get onto a scrollviewer with 3 column and unlimited lines obviously).
Below is the xmal. I have used ItemsControl and the WrapPanel as ItemsPanelTemplate to wrap the ItemsControl's items
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Content="Add" Height="26" Width="75" Command="{Binding Add}" Grid.Row="0"/>
<ScrollViewer Height="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.Row="1">
<ItemsControl ItemsSource="{Binding Items}" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="10,10,0,0" BorderBrush="Black" BorderThickness="1">
<StackPanel Width="200" Height="Auto">
<Label Content="{Binding fieldname}" FontFamily="Arial Black" FontSize="20" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0"/>
<Label Content="{Binding datebegin}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0" FontFamily="Arial Black" FontSize="18" />
<Label Content="{Binding dateend}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0" FontFamily="Arial Black" FontSize="18" />
<ProgressBar Value="{Binding progression}" Margin="5,10,5,10" Background="White" BorderBrush="Black" VerticalAlignment="Top" Height="20" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
And the viewmodel is
public class Item
{
public string fieldname
{
get;
set;
}
public string datebegin
{
get;
set;
}
public string dateend
{
get;
set;
}
public string progression
{
get;
set;
}
public Item(int number)
{
fieldname = "Filed name " + number;
datebegin = "12-12-12";
dateend = "14-12-12";
progression = (5 * number).ToString();
}
}
public class ViewModel
{
public ICollection<Item> Items
{
get;
private set;
}
public ViewModel()
{
Items = new ObservableCollection<Item>();
}
public ICommand Add
{
get
{
return new RelayCommand((a) =>
{
Items.Add(new Item(Items.Count));
});
}
}
}
Relaycommand
public class RelayCommand : ICommand
{
private Action<object> execute;
private Predicate<object> canExecute;
public RelayCommand(Action<object> execute, Predicate<object> canExecute = null)
{
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute == null || canExecute(parameter);
}
public void Execute(object parameter)
{
execute(parameter);
}
public event EventHandler CanExecuteChanged
{
add
{
CommandManager.RequerySuggested += value;
}
remove
{
CommandManager.RequerySuggested -= value;
}
}
I have a listbox with three values. I need get the FEstado value for all items of ListBox and sum them. However, this ListBox not have defined items, the user select items from another ListBox.
My Listbox:
<ListBox Name="List2" HorizontalContentAlignment="Stretch" Grid.ColumnSpan="3" Margin="0,43,-66,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="95" Hold="holdListRmv">
<TextBlock Grid.Column="0" Text="{Binding FNome}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Grid.Column="1" Text="{Binding FEstado}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Grid.Column="2" Text="{Binding Quantity}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Assuming that you populate the ListBox by adding model item to ListBox's Items property (as shown in your previous question), then you can get all items from the same ListBox.Items property. And assuming that FEstado is a number, you can do something like this :
var items = List2.Items.Cast<Fields>();
var total = items.Sum(o => o.FEstado);
You can do something like this,
try this:
XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="0">
<StackPanel>
<ListBox Name="List2" HorizontalContentAlignment="Stretch" Grid.ColumnSpan="3" Margin="0,43,-66,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="95" >
<TextBlock Grid.Column="0" Text="{Binding FNome}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Grid.Column="1" Text="{Binding FEstado}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Grid.Column="2" Text="{Binding Quantity}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="sum" Click="Button_Click_1"></Button>
</StackPanel>
</Grid>
cs:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
ObservableCollection<DataClass> obj = new ObservableCollection<DataClass>();
obj.Add(new DataClass("AA", "10", "10"));
obj.Add(new DataClass("BB", "10", "10"));
List2.ItemsSource = obj;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
int sum = 0;
for (int i = 0; i < List2.Items.Count; i++)
{
DataClass obj = (DataClass)List2.Items[i];
sum += int.Parse(obj.FEstado.ToString());
}
MessageBox.Show(sum.ToString());
}
public class DataClass
{
public string FNome { get; set; }
public string FEstado { get; set; }
public string Quantity { get; set; }
public DataClass() { }
public DataClass(string FNome, string FEstado, string Quantity)
{
this.FNome = FNome;
this.FEstado = FEstado;
this.Quantity = Quantity;
}
}
I have a window
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:GRHelper="clr-namespace:Enertek.GRHelper;assembly=Enertek.GRHelper" xmlns:local="clr-namespace:EneGR" x:Class="EneGR.SearchWindow"
Title="Main Window" Height="274.753" Width="322.345" Icon="icon.ico">
<Window.OpacityMask>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</RadialGradientBrush>
</Window.OpacityMask>
<Window.BorderBrush>
<ImageBrush Stretch="None" TileMode="FlipXY"/>
</Window.BorderBrush>
<Grid RenderTransformOrigin="0.5,0.5" Margin="0,0,2,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto" MinWidth="120"/>
<ColumnDefinition Width="65"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<Button x:Name="SearchButton" Content="Search" Grid.Column="3" Margin="0,62,0,0" VerticalAlignment="Top" Height="23" RenderTransformOrigin="0.6,0.458" FontWeight="Bold"
Click="SearchButton_Click"/>
<Label x:Name="SearchLabel" Content="Enter object's name or its part in the field below:" HorizontalAlignment="Left" Margin="0,10,0,0" VerticalAlignment="Top" Grid.ColumnSpan="4" Width="285" Height="36"/>
<Button x:Name="SearchCancel" Grid.ColumnSpan="2" Content="Cancel" HorizontalAlignment="Left" Margin="0,61,0,0" VerticalAlignment="Top" Width="120" Height="24" FontWeight="Bold"
Click=" SearchCancel_Click"/>
<TreeView Grid.Column ="1" ItemsSource="{Binding objs}" Margin="0,101,3,40" Grid.ColumnSpan="3" Background="White">
<TreeView.DataContext>
<local:MyTreeData/>
</TreeView.DataContext>
<TreeView.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Checked, Mode=TwoWay}" Content="{Binding TagName}" Checked="CheckBox_Checked"/>
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<Button x:Name="Rename" Content="Rename" Grid.Column="2" HorizontalAlignment="Left" Margin="62,212,0,0" VerticalAlignment="Top" Width="120" Grid.ColumnSpan="2" Click="Rename_Click" FontWeight="Bold"/>
<TextBox x:Name="TagNameBox" Grid.ColumnSpan="3" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="10,33,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="285"/>
<Button Content="Button" HorizontalAlignment="Left" Height="100" Margin="-106,257,0,-115" VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>
The code behind:
namespace EneGR
{
public class MyTreeData
{
public ObservableCollection<GRObject> objs { get; set; }
private bool allAreChecked = false;
public MyTreeData()
{
objs = new ObservableCollection<GRObject>();
}
public bool AllAreChecked
{
get
{
return allAreChecked;
}
set
{
allAreChecked = value;
}
}
}
/// <summary>
/// Interaction logic for SearchWindow.xaml
/// </summary>
public partial class SearchWindow : Window
{
GRGalaxy galaxy = EneGR.LoginWin.galaxy;
List <GRObject> ObjsToRename = null;
public MyTreeData TreeData = new MyTreeData();
public SearchWindow()
{
InitializeComponent();
DataContext = TreeData;
}
private void SearchCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void SearchButton_Click(object sender, RoutedEventArgs e)
{
string TagName = TagNameBox.Text;
IEnumerable<GRObject> objects = galaxy.QueryObjectsByName(TagName + '%');
MessageBox.Show(objects.Count().ToString() + " " + "Objects found" );
foreach (GRObject obj in objects)
{
TreeData.objs.Add(obj);
};
}
private void Rename_Click(object sender, RoutedEventArgs e)
{
galaxy.RenameCheckedObjects(ObjsToRename);
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
//add checked object to ienumerable collection ObjsToRename;
}
}
}
I binded objects from observable collection TreeData.objs to TreeView with CheckBoxes but they never show up in the window. I cannot understand what is wrong. IEnumerable objects is not null.
You can remove this code :
<TreeView.DataContext>
<local:MyTreeData/>
</TreeView.DataContext>
... which creates a new instance of MyTreeData and sets the TreeView's DataContext to it.
The context of your treeview is already set to the MyTreeData you want to use (because of DataContext inheritance) :
public SearchWindow()
{
InitializeComponent();
DataContext = TreeData;
}
I'm using Telerik Linear Guage to show the Accelerometer. I have three Gauge for X,Y,Z coordinates respectively.
The problem is with the value binding. I used the following code to bind the values, but it is not working,
//CodeBehind
public string XCord { get; set; }
public string YCord { get; set; }
public string ZCord { get; set; }
// Constructor
public MainPage()
{
InitializeComponent();
acc = new Accelerometer();
acc.CurrentValueChanged += acc_CurrentValueChanged;
acc.Start();
}
void acc_CurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
{
XCord = Math.Abs(acc.CurrentValue.Acceleration.X).ToString();
YCord = Math.Abs(acc.CurrentValue.Acceleration.Y).ToString();
ZCord = Math.Abs(acc.CurrentValue.Acceleration.Z).ToString();
}
<!--XAML CODE-->
<gauges:MarkerGaugeIndicator Value="57.67"
gauges:LinearGaugeRange.IndicatorOffset="40"
x:Name="indicator5"
IsAnimated="True"
IsMarkerRotated="False">
<gauges:MarkerGaugeIndicator.MarkerTemplate>
<DataTemplate>
<Grid Width="37"
Height="37">
<TextBlock x:Name="txt1" Text="{Binding XCord}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="13"
FontWeight="Bold"/>
</Grid>
</DataTemplate>
</gauges:MarkerGaugeIndicator.MarkerTemplate>
</gauges:MarkerGaugeIndicator>
<gauges:MarkerGaugeIndicator Value="57.67"
gauges:LinearGaugeRange.IndicatorOffset="40"
x:Name="indicator6"
IsAnimated="True"
IsMarkerRotated="False">
<gauges:MarkerGaugeIndicator.MarkerTemplate>
<DataTemplate>
<Grid Width="37"
Height="37">
<TextBlock x:Name="txt2" Text="{Binding YCord}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="13"
FontWeight="Bold"/>
</Grid>
</DataTemplate>
</gauges:MarkerGaugeIndicator.MarkerTemplate>
</gauges:MarkerGaugeIndicator>
<gauges:MarkerGaugeIndicator Value="57.67"
gauges:LinearGaugeRange.IndicatorOffset="40"
x:Name="indicator7"
IsAnimated="True"
IsMarkerRotated="False">
<gauges:MarkerGaugeIndicator.MarkerTemplate>
<DataTemplate>
<Grid Width="37"
Height="37">
<TextBlock x:Name="txt3" Text="{Binding ZCord}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="13"
FontWeight="Bold"/>
</Grid>
</DataTemplate>
</gauges:MarkerGaugeIndicator.MarkerTemplate>
</gauges:MarkerGaugeIndicator>
Somebody say me how to bind the value of the coordinates with the control.
So, I am on my way learning MVVM Pattern for Windows Phone, and stuck how to bind the View to my ViewModel. App that I build now is getting current and next 5 days weather and display it to one of my panorama item on MainPage.xaml using UserControl.
I cannot just simply set the Forecasts.ItemsSource = forecast; in my WeatherViewModel, it says that Forecasts (Listbox element name in WeatherView) not exist in the current context.
Can anybody teach me how to bind it? and anybody have a good source/example sample to mvvm pattern in windows-phone? Thanks before.
EDIT:
WeatherModel.cs
namespace JendelaBogor.Models
{
public class WeatherModel
{
public string Date { get; set; }
public string ObservationTime { get; set; }
public string WeatherIconURL { get; set; }
public string Temperature { get; set; }
public string TempMaxC { get; set; }
public string TempMinC { get; set; }
public string Humidity { get; set; }
public string WindSpeedKmph { get; set; }
}
}
WeatherViewModel.cs
namespace JendelaBogor.ViewModels
{
public class WeatherViewModel : ViewModelBase
{
private string weatherURL = "http://free.worldweatheronline.com/feed/weather.ashx?q=";
private const string City = "Bogor,Indonesia";
private const string APIKey = "APIKEY";
private IList<WeatherModel> _forecasts;
public IList<WeatherModel> Forecasts
{
get
{
if (_forecasts == null)
{
_forecasts = new List<WeatherModel>();
}
return _forecasts;
}
private set
{
_forecasts = value;
if (value != _forecasts)
{
_forecasts = value;
this.NotifyPropertyChanged("Forecasts");
}
}
}
public WeatherViewModel()
{
WebClient downloader = new WebClient();
Uri uri = new Uri(weatherURL + City + "&num_of_days=5&extra=localObsTime&format=xml&key=" + APIKey, UriKind.Absolute);
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(ForecastDownloaded);
downloader.DownloadStringAsync(uri);
}
private void ForecastDownloaded(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Result == null || e.Error != null)
{
MessageBox.Show("Cannot load Weather Forecast!");
}
else
{
XDocument document = XDocument.Parse(e.Result);
var current = from query in document.Descendants("current_condition")
select new WeatherModel
{
ObservationTime = DateTime.Parse((string)query.Element("localObsDateTime")).ToString("HH:mm tt"),
Temperature = (string)query.Element("temp_C"),
WeatherIconURL = (string)query.Element("weatherIconUrl"),
Humidity = (string)query.Element("humidity"),
WindSpeedKmph = (string)query.Element("windspeedKmph")
};
this.Forecasts = (from query in document.Descendants("weather")
select new WeatherModel
{
Date = DateTime.Parse((string)query.Element("date")).ToString("dddd"),
TempMaxC = (string)query.Element("tempMaxC"),
TempMinC = (string)query.Element("tempMinC"),
WeatherIconURL = (string)query.Element("weatherIconUrl")
}).ToList();
}
}
}
}
WeatherView.xaml
<UserControl x:Class="JendelaBogor.Views.WeatherView"
xmlns:vm="clr-namespace:JendelaBogor.ViewModels">
<UserControl.DataContext>
<vm:WeatherViewModel />
</UserControl.DataContext>
<Grid Margin="0,-10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="Current" Grid.Row="0" Height="150" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" delay:LowProfileImageLoader.UriSource="{Binding WeatherIconURL}" Width="120" Height="120" VerticalAlignment="Top"/>
<StackPanel Grid.Column="1" Height="200" VerticalAlignment="Top">
<TextBlock Text="{Binding Temperature}" FontSize="22"/>
<TextBlock Text="{Binding ObservationTime}" FontSize="22"/>
<TextBlock Text="{Binding Humidity}" FontSize="22"/>
<TextBlock Text="{Binding Windspeed}" FontSize="22"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Height="300" VerticalAlignment="Bottom" Margin="10,0,0,0">
<StackPanel VerticalAlignment="Top">
<StackPanel Height="40" Orientation="Horizontal" Margin="0,0,0,0">
<TextBlock Text="Date" FontSize="22" Width="170"/>
<TextBlock Text="FC" FontSize="22" Width="60"/>
<TextBlock Text="Max" TextAlignment="Right" FontSize="22" Width="90"/>
<TextBlock Text="Min" TextAlignment="Right" FontSize="22" Width="90"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<ListBox ItemsSource="{Binding Forecasts}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="40" Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="{Binding Date}" FontSize="22" TextAlignment="Left" Width="170" />
<Image delay:LowProfileImageLoader.UriSource="{Binding WeatherIconURL}" Width="40" Height="40" />
<TextBlock Text="{Binding TempMaxC, StringFormat='\{0\} °C'}" TextAlignment="Right" FontSize="22" Width="90" />
<TextBlock Text="{Binding TempMinC, StringFormat='\{0\} °C'}" TextAlignment="Right" FontSize="22" Width="90" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</UserControl>
MainPage.xaml
<controls:PanoramaItem x:Name="Weather" Header="weather">
<views:WeatherView />
</controls:PanoramaItem>
You need to tell the view what viewmodel you are using. By adding
<UserControl
xmlns:vm="clr-namespace:JendelaBogor.ViewModels">
<UserControl.DataContext>
<vm:WeatherViewModel />
</UserControl.DataContext>
</UserControl>
all {Binding}'s are mapped to the class WeatherViewModel. By using the ItemsSource property on the listbox as Reed suggests you can then bind all items from a list that you expose through a property.
If the list is ever changed while running the application, consider using an ObservableCollection and clearing it and adding all new items when new data is received. If you do, your GUI will simply update with it.
The ViewModel doesn't know about the view.
You need to make a Forecasts property on the ViewModel, and bind the ItemsSource to it from your View. In your view, change the ListBox to:
<!-- No need for a name - just add the binding -->
<ListBox ItemsSource="{Binding Forecasts}">
Then, in your ViewModel, add:
// Add a backing field
private IList<WeatherModel> forecasts;
// Add a property implementing INPC
public IList<WeatherModel> Forecasts
{
get { return forecasts; }
private set
{
forecasts = value;
this.RaisePropertyChanged("Forecasts");
}
}
You can then set this in your method:
this.Forecasts = (from query in document.Descendants("weather")
select new WeatherModel
{
Date = DateTime.Parse((string)query.Element("date")).ToString("dddd"),
TempMaxC = (string)query.Element("tempMaxC"),
TempMinC = (string)query.Element("tempMinC"),
WeatherIconURL = (string)query.Element("weatherIconUrl")
})
.ToList(); // Turn this into a List<T>