本文整理汇总了C#中System.Windows.Documents.List.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# List.Cast方法的具体用法?C# List.Cast怎么用?C# List.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Cast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TagPickerView
//TagPickerTagCollection tagPickerTags;
public TagPickerView()
{
InitializeComponent();
addTagAutoCompleteBox.CustomFindMatchesFunction = new UserControls.AutoCompleteBox.AutoCompleteBoxView.CustomFindMatchesDelegate((text) =>
{
List<Tag> results = new List<Tag>();
using (TagDbCommands tc = new TagDbCommands())
{
results = tc.getTagAutocompleteMatches(text, 50, IsStartsWithAutoCompleteMode);
}
return (results.Cast<Object>().ToList());
});
DependencyPropertyDescriptor.FromProperty(AutoCompleteBoxView.TextProperty, typeof(AutoCompleteBoxView)).AddValueChanged(addTagAutoCompleteBox, addTagAutoCompleteBox_TextChanged);
DependencyPropertyDescriptor.FromProperty(AutoCompleteBoxView.SelectedItemProperty, typeof(AutoCompleteBoxView)).AddValueChanged(addTagAutoCompleteBox, addTagAutoCompleteBox_SelectedItemChanged);
addButton.IsEnabled = false;
clearButton.IsEnabled = false;
selectedTags = new List<ToggleButton>();
}
示例2: Convert
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values.Any(obj => obj == DependencyProperty.UnsetValue))
return DependencyProperty.UnsetValue;
if ((string)parameter == "ganttLine")
{
var length = ((DateTime)values[0] - (DateTime)values[1]).TotalMinutes / 30;
var interval = (double)values[2];
return length * interval;
}
else
{
var vals = new List<double>();
foreach (object val in values)
//box化されたintがdoubleへ直接キャストできないのでいったんunbox化した後にdoubleにする
vals.Add(val is int ? (double)(int)val : (double)val);
switch ((string)parameter)
{
case "sum":
return vals.Cast<double>().Sum();
case "product":
return vals.Aggregate((val, tmp) => val * tmp);
default:
throw new NotImplementedException();
}
}
}