本文整理汇总了C#中System.Collections.ObservableCollection.RemoveRange方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.RemoveRange方法的具体用法?C# ObservableCollection.RemoveRange怎么用?C# ObservableCollection.RemoveRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.RemoveRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}