This file contains 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
namespace Okazuki.WinRT.Common | |
{ | |
using System.Collections.Generic; | |
using System.Linq; | |
using Windows.Foundation.Collections; | |
class ObservableVector<T> : IObservableVector<T> | |
{ | |
private List<T> inner; |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Windows.Input; | |
namespace Application3.Common | |
{ | |
class DelegateCommand : ICommand | |
{ | |
private static readonly Action EmptyExecute = () => { }; | |
private static readonly Func<bool> EmptyCanExecute = () => true; |
This file contains 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
*[WinRT][MEF]WinRTのMEFでServiceLocator実装してみた | |
WinRTのMEFってCompositionContainerクラスがいなくなってCompositionServiceクラスでSatisfyImportsOnceメソッド使って対象クラスに何かをImportするということしかできないっぽいです。なのでMVVM Light 4のDIコンテナにMEF使ってやろうと思ったらいきなり挫折してしまいましたorz | |
それじゃぁ悔しいので、無理やりCompositionServiceクラスを使った状態でIServiceLocatorインターフェースを実装してみました。ちなみにMVVM Light 4に添付されてるMicrosoft.Practices.ServiceLocation.dllを使います。 | |
**実装 | |
ということでさくっと実装してみました。SatisfyImportsOnceメソッドにRegistrationBuilderのインスタンスを渡せば実行時にImportの挙動とかをいじれるみたいなので、それを使ってごにょごにょっとしてます。 | |
>|cs| | |
namespace SampleImplementation | |
{ |
This file contains 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
void Main() | |
{ | |
var catalog = new AssemblyCatalog(typeof(A<>).Assembly); | |
var container = new CompositionContainer(catalog); | |
var a = container.GetExportedValue<A<string>>(); | |
a.Dump(); | |
container.ComposeParts(this); | |
var export = this.AProperty.CreateExport(); | |
var value = export.Value; |
This file contains 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
using System.ServiceModel.DomainServices.Client; | |
using System.Windows; | |
using System.Windows.Controls; | |
using SilverlightApplication1.Web; | |
namespace SilverlightApplication1 | |
{ | |
/// <summary> | |
/// Button2つとDataGridを1つ適当に置いた画面のコードビハインド | |
/// </summary> |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reactive; | |
using System.Reactive.Linq; | |
using System.Reactive.Subjects; | |
using System.ServiceModel.DomainServices.Client; | |
using System.Windows; | |
using System.Windows.Controls; | |
using SilverlightApplication1.Web; |
This file contains 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
<Window x:Class="WpfApplication2.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<ItemsControl ItemsSource="{Binding Items}"> | |
<ItemsControl.ItemTemplate> | |
<DataTemplate> | |
<StackPanel Orientation="Horizontal"> | |
<TextBox Text="{Binding Text}" /> |
This file contains 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
template<typename TProgress> | |
class BackgroundWorker | |
{ | |
private: | |
TProgress progress_; | |
bool reportChanged_; | |
public: | |
BackgroundWorker(bool reportChanged = false) : | |
progress_(TProgress()), | |
reportChanged_(reportChanged) |
This file contains 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
<Window x:Class="WpfApplication1.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:l="clr-namespace:WpfApplication1" | |
Title="MainWindow" Height="350" Width="525"> | |
<Window.Resources> | |
<l:FirstConverter x:Key="FirstConverter"/> | |
</Window.Resources> | |
<Window.DataContext> | |
<l:MainWindowViewModel /> |
This file contains 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 a = new ObservableCollection<string>(); | |
var b = new ObservableCollection<string>(); | |
var rc = a.ToCollectionChanged() | |
.Merge(b.ToCollectionChanged().Select(x => new CollectionChanged<string> | |
{ | |
Action = x.Action, | |
Index = x.Index + a.Count, | |
OldIndex = x.OldIndex + a.Count, | |
Value = x.Value, |