本文整理汇总了C#中System.Collections.ObservableCollection.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.Select方法的具体用法?C# ObservableCollection.Select怎么用?C# ObservableCollection.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.Select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MemberListViewModel
/// <summary>
/// <see cref="MemberListViewModel"/>インスタンスを生成し, インスタンスが持つModelを初期化する.
/// </summary>
/// <param name="modelData">
/// 生成した<see cref="MemberListViewModel"/>インスタンスで扱いたい全メンバーの<see cref="IPerson"/>のコレクション.
/// 生成したインスタンスに持たせるModelの値として用いられる.
/// </param>
public MemberListViewModel(ObservableCollection<IPerson> modelData)
{
model = modelData;
Members = model.Select(person => new MemberListItemViewModel(person)).Cast<IMemberListItemViewModel>().ToList();
foreach (IMemberListItemViewModel memberViewModel in Members)
{
memberViewModel.MemberClick += Item_MemberClick;
memberViewModel.MemberExtendedClick += Item_MemberExtendedClick;
}
}
示例2: IniMyStuff
private void IniMyStuff()
{
//Luodaan conteksti = datasisältö
ctx = new BookShopEntities();
//Ladataan kirjatiedot paikalliseksi
ctx.Books.Load();
localBooks = ctx.Books.Local;
//täytetään comboxi kirjailijoiden maiden nimillä
cbCountries.DataContext = localBooks.Select(n => n.country).Distinct();
view = CollectionViewSource.GetDefaultView(localBooks);
}
示例3: IniMyStuff
private void IniMyStuff() {
// luodaan konteksti = datasisältö
ctx = new BookShopEntities();
// ladataan kirjojen tiedot paikalliseksi
ctx.Books.Load();
localBooks = ctx.Books.Local;
// täytetään combobox kirjailijoitten maiden nimillä
// huom: lambda-tyylin LINQ-kysely
cbCountries.DataContext = localBooks.Select(n => n.country).Distinct();
// luodaan view
view = CollectionViewSource.GetDefaultView(localBooks);
}
示例4: init
public void init()
{
// Luodaan konteksti = datasisältö
ctx = new BookShopEntities();
// Ladataan kirjatiedot paikalliseksi
ctx.Books.Load();
localBooks = ctx.Books.Local;
// Täytetään comboboksi kirjailiijoitten maitten nimillä. 101 LINQ SAMPLES
cmbMaa.DataContext = localBooks.Select(n => n.country).Distinct();
// Luodaan view
view = CollectionViewSource.GetDefaultView(localBooks);
}
示例5: IniMyStuff
private void IniMyStuff()
{
// luodaan konteksti aka datasisältö
ctx = new BookShopEntities();
// ladataan kirjatiedot paikalliseksi
ctx.Books.Load();
//ctx.Customers.Load();
localbooks = ctx.Books.Local;
// täytetään comboboksi kirjailijoiden maiden nimillä
// huoma lambda tyypin linq kysely
cbFilter.DataContext = localbooks.Select(n => n.country).Distinct();
// luodaan view
view = CollectionViewSource.GetDefaultView(localbooks);
}
示例6: CreateDisplayModel
internal static ObservableCollection<LinkedParameterDisplayModel> CreateDisplayModel(ObservableCollection<LinkedParameterModel> observableCollection)
{
return new ObservableCollection<LinkedParameterDisplayModel>(observableCollection.Select(lp => new LinkedParameterDisplayModel(lp)));
}
示例7: WindowViewModel
public WindowViewModel(IObjectProvider objectProvider,
IWindowFactory windowFactory,
ILogger logger,
IWindowsController windowsController,
RecentFilesViewModel recentFilesViewModel,
GeneralOptionsViewModel generalOptionsViewModel,
ISchedulerProvider schedulerProvider)
{
_logger = logger;
_windowsController = windowsController;
RecentFiles = recentFilesViewModel;
Views = new ObservableCollection<ViewContainer>();
GeneralOptions = generalOptionsViewModel;
_schedulerProvider = schedulerProvider;
_objectProvider = objectProvider;
InterTabClient = new InterTabClient(windowFactory);
DropMonitor = new FileDropMonitor();
OpenFileCommand = new Command(OpenFile);
ShowInGitHubCommand = new Command(()=> Process.Start("https://github.com/RolandPheasant"));
ZoomOutCommand= new Command(()=> { GeneralOptions.Scale = GeneralOptions.Scale + 5; });
ZoomInCommand = new Command(() => { GeneralOptions.Scale = GeneralOptions.Scale - 5; });
Version = "v" + Assembly.GetEntryAssembly().GetName().Version.ToString(3);
var fileDropped = DropMonitor.Dropped.Subscribe(OpenFile);
var isEmptyChecker = Views.ToObservableChangeSet()
.ToCollection()
.Select(items=>items.Count)
.StartWith(0)
.Select(count=>count==0)
.Subscribe(isEmpty=> IsEmpty = isEmpty);
var openRecent = recentFilesViewModel.OpenFileRequest
.Subscribe(file =>
{
MenuIsOpen = false;
OpenFile(file);
});
_cleanUp = new CompositeDisposable(recentFilesViewModel,
isEmptyChecker,
fileDropped,
DropMonitor,
openRecent,
Disposable.Create(() =>
{
Views.Select(vc => vc.Content)
.OfType<IDisposable>()
.ForEach(d=>d.Dispose());
}));
}
示例8: data_SectionStoriesDownloadCompleted
static void data_SectionStoriesDownloadCompleted(object sender,
DownloadStringCompletedEventArgs downloadCompletedEvent,
ObservableCollection<Story> storyCollection,
Section section,
InsertStoriesAt insertStoriesAt)
{
if (downloadCompletedEvent.Error != null)
{
DownloadFailed(sender, downloadCompletedEvent);
return;
}
SunApiAdapter.handleJsonWithSanitization(
(json) =>
{
var stories = SunApiAdapter.StoriesOfApiResponse(json);
var existingNids = storyCollection.Select(s => s.Nid);
int countStoriesAdded = insertStoriesAt == InsertStoriesAt.Beginning ? 0 : storyCollection.Count;
foreach (Story story in stories.Where(article => !existingNids.Contains(article.Nid)))
{
story.Vid = section.Vid;
// cached stories will already be present
// so we want to add the new stuff to the beginning
// Do we need to sort anyway, or will this always work?
storyCollection.Insert(countStoriesAdded++, story);
}
},
() =>
{
Debug.Assert(false, "Why couldn't the JSON be parsed?");
DownloadFailed(sender, downloadCompletedEvent);
},
downloadCompletedEvent.Result
);
}
示例9: Init
public void Init(Model model) {
InitializeComponent();
OnCompleted += () => {
disposables.Dispose();
};
var availableActions = new ObservableCollection<Action1>();
var includedActions = new ObservableCollection<Action1>();
var applyCommand = new DelegateCommand(
() => {
model.trigger.Configuration.TopicExpression = GetTopicExression();
if (string.IsNullOrEmpty(model.trigger.Configuration.TopicExpression.Any.First().InnerText))
model.trigger.Configuration.TopicExpression = null;
if (string.IsNullOrEmpty(model.trigger.Configuration.ContentExpression.Any.First().InnerText))
model.trigger.Configuration.ContentExpression = null;
model.trigger.Configuration.ActionToken = includedActions.Select(a => a.Token).ToArray();
Success(new Result.Apply(model));
},
() => true
);
applyButton.Command = applyCommand;
var cancelCommand = new DelegateCommand(
() => Success(new Result.Cancel(model)),
() => true
);
cancelButton.Command = cancelCommand;
FixModel(model);
{ // token
valueToken.CreateBinding(TextBlock.TextProperty, model.trigger, x => x.Token);
if (string.IsNullOrEmpty(model.trigger.Token)) {
captionToken.Visibility = Visibility.Collapsed;
valueToken.Visibility = Visibility.Collapsed;
}
}
{ // topic filter
var concreteSetTopics = GetConcreteSetTopics(model.topicSet);
concreteSetTopics.Insert(0, string.Empty);
var topicExpr = model.trigger.Configuration.TopicExpression.Any.First().InnerText;
var topicExprParts = topicExpr.Split(new char[] { '|' });
foreach (var part in topicExprParts) {
var control = CreateTopicExprControl(concreteSetTopics, part);
valuesTopicExpr.Items.Add(control);
}
var addTopicExprPartCommand = new DelegateCommand(
executeMethod: () => {
var control = CreateTopicExprControl(concreteSetTopics, string.Empty);
valuesTopicExpr.Items.Add(control);
},
canExecuteMethod: () => valuesTopicExpr.Items.Count <= 32
);
addTopicExprPartButton.Command = addTopicExprPartCommand;
}
{ // content filter
valueContentExpr.CreateBinding(TextBox.TextProperty, model.trigger.Configuration.ContentExpression
, m => m.Any.First().InnerText
, (m, v) => m.Any = new XmlNode[] { new XmlDocument().CreateTextNode(v) });
}
{ // actions
var addActionCommand = new DelegateCommand(
() => {
var actions = (listAvailableActions.SelectedItems ?? new ArrayList()).Select(i => (Action1)i).ToList();
availableActions.RemoveRange(actions);
includedActions.AddRange(actions);
},
() => (listAvailableActions.SelectedItems ?? new ArrayList()).Count > 0
);
addActionButton.Command = addActionCommand;
var removeActionCommand = new DelegateCommand(
() => {
var actions = (listIncludedActions.SelectedItems ?? new ArrayList()).Select(i => (Action1)i).ToList();
includedActions.RemoveRange(actions);
availableActions.AddRange(actions);
},
() => (listIncludedActions.SelectedItems ?? new ArrayList()).Count > 0
);
removeActionButton.Command = removeActionCommand;
includedActions.AddRange(model.trigger.Configuration.ActionToken.Select(token => model.actions.First(a => a.Token == token)).ToList());
availableActions.AddRange(model.actions.Except(includedActions).ToList());
listAvailableActions.ItemsSource = availableActions;
listIncludedActions.ItemsSource = includedActions;
listIncludedActions.SelectionChanged += delegate { removeActionCommand.RaiseCanExecuteChanged(); };
listAvailableActions.SelectionChanged += delegate { addActionCommand.RaiseCanExecuteChanged(); };
}
Localization();
}