This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var listToModify = new List<string>(); | |
var listNotToModify = new List<string>(); | |
var bindingListWrapper = new BindingList<string>(listToModify); // wrapper modifies inner list | |
var bindingListCopy = new BindingList<string>(listNotToModify.ToList()); // doesn't change original list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView IsItemClickEnabled="True" | |
ItemsSource="{Binding Items}" | |
ItemClick="OnItemClick" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AttachedProperties | |
{ | |
public static DependencyProperty ItemClickCommandProperty = | |
DependencyProperty.RegisterAttached("ItemClickCommand", | |
typeof(ICommand), | |
typeof(AttachedProperties), | |
new PropertyMetadata(null, OnItemClickCommandChanged)); | |
public static void SetItemClickCommand(DependencyObject target, ICommand value) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView IsItemClickEnabled="True" | |
ItemsSource="{Binding Items}"> | |
<i:Interaction.Behaviors> | |
<local:ItemClickedBehavior ItemClickedCommand="{Binding ItemClickedCommand}" /> | |
</i:Interaction.Behaviors> | |
</ListView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListView IsItemClickEnabled="True" | |
ItemsSource="{Binding Items}"> | |
<i:Interaction.Triggers> | |
<i:EventTrigger EventName="ItemClick"> | |
<i:InvokeCommandAction Command="{Binding ItemClickedCommand}" /> | |
</i:EventTrigger> | |
</i:Interaction.Triggers> | |
</ListView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page.Resources> | |
<b:NameScopeBinding x:Key="ListView" Source="{Binding ElementName=ListView}" /> | |
</Page.Resources> | |
<ListView x:Name="ListView" | |
SelectionMode="Single" | |
IsItemClickEnabled="True" | |
ItemsSource="{Binding Items}"> | |
<i:Interaction.Triggers> | |
<i:EventTrigger EventName="ItemClick"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Grid Width="60" Height="60" | |
VerticalAlignment="Top" | |
Background="{StaticResource PhoneAccentBrush}"> | |
<Image Source="{Binding LogType, Converter={StaticResource EnumToImageConverter}}" /> | |
</Grid> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EnumToImageConverter : IValueConverter | |
{ | |
public string SubFolder { get; set; } | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
if (value is Enum && targetType == typeof(ImageSource)) | |
{ | |
var enumType = value.GetType(); | |
var format = String.IsNullOrEmpty(SubFolder) ? "/Assets/{0}/{2}.png" : "/Assets/{0}/{1}/{2}.png"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<byte[]> ReadAsync(string filename) | |
{ | |
var fileInfo = new FileInfo(filename); | |
using (var stream = new FileStream(filename, FileMode.Open)) | |
{ | |
var buffer = new byte[fileInfo.Length]; | |
await Task<int>.Factory.FromAsync(stream.BeginRead, stream.EndRead, buffer, 0, buffer.Length, null); | |
return buffer; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Task<string> DownloadStringAsync(Uri uri) | |
{ | |
var taskSource = new TaskCompletionSource<string>(); | |
var webClient = new WebClient(); | |
webClient.DownloadStringCompleted += (sender, args) => | |
{ | |
try | |
{ | |
if (args.Error != null) |