本文整理汇总了C#中ObservableCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.Add方法的具体用法?C# ObservableCollection.Add怎么用?C# ObservableCollection.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectControlViewModel_AddNewServer_ResourceRepositoryReturnExistingServers_False
public void ConnectControlViewModel_AddNewServer_ResourceRepositoryReturnExistingServers_False()
{
//------------Setup for test--------------------------
var mainViewModel = new Mock<IMainViewModel>();
var connectControlSingleton = new Mock<IConnectControlSingleton>();
var env1 = new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(true, false).Object, new Mock<IResourceRepository>().Object, false);
var env2 = new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(true, false).Object, new Mock<IResourceRepository>().Object, false);
var connectControlEnvironments = new ObservableCollection<IConnectControlEnvironment>();
var controEnv1 = new Mock<IConnectControlEnvironment>();
var controEnv2 = new Mock<IConnectControlEnvironment>();
controEnv1.Setup(c => c.EnvironmentModel).Returns(env1);
controEnv2.Setup(c => c.EnvironmentModel).Returns(env2);
controEnv1.Setup(c => c.IsConnected).Returns(true);
connectControlEnvironments.Add(controEnv2.Object);
connectControlEnvironments.Add(controEnv1.Object);
connectControlSingleton.Setup(c => c.Servers).Returns(connectControlEnvironments);
var environmentRepository = new Mock<IEnvironmentRepository>();
ICollection<IEnvironmentModel> environments = new Collection<IEnvironmentModel>
{
env1
};
environmentRepository.Setup(e => e.All()).Returns(environments);
var viewModel = new ConnectControlViewModel(mainViewModel.Object, environmentRepository.Object, e => { }, connectControlSingleton.Object, "TEST : ", false);
//------------Execution-------------------------------
int serverIndex;
var didAddNew = viewModel.AddNewServer(out serverIndex, i => { });
//------------Assert----------------------------------
Assert.IsNotNull(viewModel);
Assert.IsFalse(didAddNew);
}
示例2: ModuloAdminViewModel
public ModuloAdminViewModel()// TODO Enviar el usuario logueado y sacar su rol
{
_children = new ObservableCollection<object>();
_children.Add(ListarFisioterapeutasViewModel.Instance());
_children.Add(ListarPacientesViewModel.Instance());
_children.Add(ListaPacientesAsociacionViewModel.Instance());
_children.Add(ListarResultadosReportesViewModel.Instance());
_children.Add(RutasAlmacenamientoViewModel.Instance());
CloseWindowFlag = true;
BlnSavePathNoExist = false;
iTabSelected = 0;
CerrarSesionCommand = new RelayCommand(CerrarSesion);
RolLogueado = "Administrador";
if (RutasConfiguracionDL.ObtenerConfiguraciones().Count == 0)
{
// the view does not recognize this variables, then is not possible to see an UI update
BlnSavePathNoExist = true;
iTabSelected = 4;
//Manually fixed
System.Windows.Forms.MessageBox.Show("Aún no ha determinado la rutas de almacenamiento de las fotos y exportaciones de archivos PDF. Por favor dirigirse a la pestaña Rutas de Almacenamiento para determinar las rutas de almacenamiento.", "Advertencia", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
}
//cargamos las configuranes de base de datos
}
示例3: MenuGeneral
public MenuGeneral()
{
//Delegate pour exécuter du code personnalisé lors du changement de langue de l'UI.
CultureManager.UICultureChanged += CultureManager_UICultureChanged;
mapLangue = new ObservableCollection<LangueUI>();
//Le tag de langue IETF (ie: fr-CA) utilisé directement pour changer la langue d'affichage.
//Récupéré selon la Langue active.
string codeLangueActif;
//Si l'utilisateur est connecté, utilise la langue sauvegarder sous son profil.
if (App.MembreCourant.IdMembre != null)
{
codeLangueActif = App.MembreCourant.LangueMembre.IETF;
}
else
{
//Sinon, utilise la valeur par défault tel que défini sous App.
codeLangueActif = App.LangueInstance.IETF;
}
mapLangue.Add(francais);
mapLangue.Add(anglais);
//Dans le dictionnaire, trouve l'élément qui a le tag IETF équivalent à selui enregistré sous codeLangueActif et le met à actif.
mapLangue.FirstOrDefault(l => l.LangueSys.IETF == codeLangueActif).Actif = true;
InitializeComponent();
//Configure la source de notre dataGrid.
dgLangues.ItemsSource = mapLangue;
}
示例4: GetMenuItems
public ObservableCollection<MenuItem> GetMenuItems()
{
ObservableCollection<MenuItem> items = new ObservableCollection<MenuItem>();
MenuItem copyItem = new MenuItem()
{
IconUrl = new Uri("Images/copy.png", UriKind.Relative),
Text = "Copy",
Command = new CopyCommand()
};
items.Add(copyItem);
MenuItem pasteItem = new MenuItem()
{
IconUrl = new Uri("Images/paste.png", UriKind.Relative),
Text = "Paste",
Command = new PasteCommand()
};
items.Add(pasteItem);
MenuItem cutItem = new MenuItem()
{
IconUrl = new Uri("Images/cut.png", UriKind.Relative),
Text = "Cut",
Command = new CutCommand()
};
items.Add(cutItem);
return items;
}
示例5: GetMockedTweets
public ObservableCollection<TwitterDataItem> GetMockedTweets()
{
var ret = new ObservableCollection<TwitterDataItem>();
ret.Add(new TwitterDataItem("12389741623598172",
"@techdrinkup",
"2190675848",
"http://a0.twimg.com/sticky/default_profile_images/default_profile_0.png",
"#Test waschtrockner stiftung warentest http://t.co/b9GyagIs #shop #tests waschtrockner stiftung warentest kaufen"));
ret.Add(new TwitterDataItem("12389741623598173",
"@lucasvidalutn",
"208112063",
"https://twimg0-a.akamaihd.net/profile_images/1473386819/profile.jpg",
"RT @ShauniLatu: “@blasfloss: Time to #fail this #math #test...” You fail at life."));
ret.Add(new TwitterDataItem("12389741623598174",
"@oso_arturo",
"467767993",
"http://a0.twimg.com/profile_images/2191494082/virtuellemiss.jpg",
"#2010 #maximebataille #test #coiffure #mode #model #mannequin http://t.co/yiQEygfr"));
ret.Add(new TwitterDataItem("12389741623598175",
"@ggonzalez30",
"241319155",
"http://a0.twimg.com/profile_images/2639300174/19fcbfeb78327fc6329c9d877b5b69dc.jpeg",
"Time to #fail this #math #test..."));
ret.Add(new TwitterDataItem("123897416235981726",
"@juan_carlos_batman",
"824545292",
"https://twimg0-a.akamaihd.net/profile_images/2475729655/gjr49jeorqfcd6rm7djv.jpeg",
"Studying all this week better have been worth it for my test on monday #collegebound #test"));
return ret;
}
示例6: ExtensionUploadWarningDialog
public ExtensionUploadWarningDialog(IEnumerable<string> errors, IEnumerable<string> warnings)
{
InitializeComponent();
DataContext = this;
Messages = new ObservableCollection<Dictionary<string, string>>();
foreach (string error in errors)
{
Dictionary<string, string> message = new Dictionary<string, string>();
message.Add("message", error);
message.Add("image", "/ESRI.ArcGIS.Mapping.Controls;component/Images/icons/warning_icon.png");
Messages.Add(message);
}
foreach (string warning in warnings)
{
Dictionary<string, string> message = new Dictionary<string, string>();
message.Add("message", warning);
message.Add("image", "/ESRI.ArcGIS.Mapping.Controls;component/Images/icons/caution16.png");
Messages.Add(message);
}
HasErrors = errors.Count() > 0;
}
示例7: LoadFilters
public void LoadFilters()
{
var bw = new ImageFilter(new BlackAndWhite());
var sepia = new ImageFilter(new Sepia()) { Value = 20 };
var brightness = new ImageFilter(new Brightness()) { Value = 20 };
var contrast = new ImageFilter(new Contrast()) { Value = 20 };
var filters = new ObservableCollection<ImageFilter> { bw, sepia };
bool isBrightnessBought;
if (IsolatedStorageSettings.ApplicationSettings.TryGetValue(InAppProducts.BrightnessFilterIdentifier,
out isBrightnessBought))
{
if (isBrightnessBought)
{
filters.Add(brightness);
}
}
bool isContrastBought;
if (IsolatedStorageSettings.ApplicationSettings.TryGetValue(InAppProducts.ContrastFilterIdentifier,
out isContrastBought))
{
if (isContrastBought)
{
filters.Add(contrast);
}
}
Filters = filters;
SelectedFilter = Filters.First();
}
示例8: ReplaceColorBlockItemsFromString_MultipleLines_ExistingBlockItems
public void ReplaceColorBlockItemsFromString_MultipleLines_ExistingBlockItems()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red);
var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue);
var testInpuBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow);
testInputBlockItems.Add(testInputTextColorBlockItem);
testInputBlockItems.Add(testInputBackgroundColorBlockItem);
testInputBlockItems.Add(testInpuBorderColorBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreNotSame(testInputTextColorBlockItem, textColorBlockItem);
Assert.AreEqual(new Color {A = 255, R = 240, G = 200, B = 150}, textColorBlockItem.Color);
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreNotSame(testInputBackgroundColorBlockItem, backgroundColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color);
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
Assert.IsNotNull(borderColorBlockItem);
Assert.AreNotSame(testInpuBorderColorBlockItem, borderColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
}
示例9: SettingsViewModel
public SettingsViewModel()
{
SendMethodCollection = new ObservableCollection<string>();
SendMethodCollection.Add(StringResources.SettingsPage_Settings_SMS);
SendMethodCollection.Add(StringResources.SettingsPage_Settings_Email);
}
示例10: InitializeBootAddressList
private void InitializeBootAddressList()
{
BootAddressList = new ObservableCollection<string>();
BootAddressList.Add("0x0000~0x8000");
BootAddressList.Add("0x8000~0xC000");
}
示例11: MenuViewModel
public MenuViewModel()
{
CanLoadMore = true;
Title = "MasterDetailTabbed";
MenuItems = new ObservableCollection<HomeMenuItem>();
MenuItems.Add(new HomeMenuItem
{
Id = 0,
Title = "Home",
MenuType = MenuType.Home,
Icon = "home.png"
});
MenuItems.Add(new HomeMenuItem
{
Id = 5,
Title = "Feedback",
MenuType = MenuType.Feedback,
Icon = "feedback.png"
});
MenuItems.Add(new HomeMenuItem
{
Id = 6,
Title = "About",
MenuType = MenuType.About,
Icon = "about.png"
});
}
示例12: Linq_Test_Employees
public void Linq_Test_Employees()
{
var violation = false;
var employees = new ObservableCollection<Person>();
var employeesWithUpdates = employees.WithUpdates();
var violations = from employee in employeesWithUpdates
where employee.WorkItems > 2 *
(from collegue in employeesWithUpdates
where collegue.Team == employee.Team
select collegue.WorkItems).Average()
select employee.Name;
violations.CollectionChanged += (o, e) =>
{
violation = true;
};
Assert.IsFalse(violation);
employees.Add(new Person() { Name = "John", WorkItems = 20, Team = "A" });
Assert.IsFalse(violation);
employees.Add(new Person() { Name = "Susi", WorkItems = 5, Team = "A" });
Assert.IsFalse(violation);
employees.Add(new Person() { Name = "Joe", WorkItems = 3, Team = "A" });
Assert.IsTrue(violation);
}
示例13: ScreenVirtualContainer_VM
public ScreenVirtualContainer_VM()
{
PreviewFirstVirtualMode = VirtualModeType.Led3;
PreviewSecondVirtualMode = VirtualModeType.Led31;
ObservableCollection<VirtualLightType> sequence = new ObservableCollection<VirtualLightType>();
sequence.Add(VirtualLightType.Red);
sequence.Add(VirtualLightType.Green);
sequence.Add(VirtualLightType.Blue);
sequence.Add(VirtualLightType.VRed);
LightSequence = sequence;
LightSequence.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(LightSequence_CollectionChanged);
sequence = new ObservableCollection<VirtualLightType>();
sequence.Add(VirtualLightType.Red);
sequence.Add(VirtualLightType.Green);
sequence.Add(VirtualLightType.Blue);
sequence.Add(VirtualLightType.VRed);
PreviewFirstLightSequence = sequence;
PreviewFirstLightSequence.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(LightSequence_CollectionChanged1);
sequence = new ObservableCollection<VirtualLightType>();
sequence.Add(VirtualLightType.VRed);
sequence.Add(VirtualLightType.Blue);
sequence.Add(VirtualLightType.Red);
sequence.Add(VirtualLightType.Green);
PreviewSecondLightSequence = sequence;
PreviewSecondLightSequence.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(LightSequence_CollectionChanged2);
}
示例14: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string photoId = NavigationContext.QueryString["photo_id"];
photo = Cinderella.CinderellaCore.PhotoCache[photoId];
// Prepare data source
dataSource = new ObservableCollection<ModelBase>();
dataSource.Add(photo);
foreach (var comment in photo.Comments)
{
dataSource.Add(comment);
}
CommentsListView.ItemsSource = dataSource;
// App bar
ApplicationBar = Resources["PhotoPageAppBar"] as ApplicationBar;
// Background
if (PolicyKit.ShouldUseBlurredBackground)
BackgroundImage.PhotoSource = photo;
else if (BackgroundImage.PhotoSource != null)
BackgroundImage.PhotoSource = null;
}
示例15: TrackListViewModel
public TrackListViewModel()
{
Tracks = new ObservableCollection<Track>();
SelectedTracks = new ObservableCollection<Track>();
if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
{
// designtime data
var album = new Album()
{
AlbumArtist = new Artist()
{
Name = "Miles Davis"
},
Name = "Kind of Blue",
ImageSource = "https://upload.wikimedia.org/wikipedia/en/9/9c/MilesDavisKindofBlue.jpg",
Year = 1969,
DateImported = new DateTime(1987, 6, 19)
};
Tracks.Add(new Track() { TrackNumber = 1, Album = album, Artist = album.AlbumArtist, Name = "So What" });
Tracks.Add(new Track() { TrackNumber = 2, Album = album, Artist = album.AlbumArtist, Name = "Freddie Freeloader" });
Tracks.Add(new Track() { TrackNumber = 3, Album = album, Artist = album.AlbumArtist, Name = "Blue in Green" });
Tracks.Add(new Track() { TrackNumber = 4, Album = album, Artist = album.AlbumArtist, Name = "All Blues" });
Tracks.Add(new Track() { TrackNumber = 5, Album = album, Artist = album.AlbumArtist, Name = "Flamenco Sketches" });
return;
}
}