Exemplo n.º 1
0
        /// <summary>
        /// Load live tiles configuration data provider. Random products are used to populate live tile. 
        /// </summary>
        /// <returns></returns>
        private async void GetTilesAsync()
        {
            var randomProducts = await ProductDataSource.GetRandomProductsAsync(3);

            foreach (var product in randomProducts)
            {
                var tile = new Tile
                {
                    Text1 = product.Name,
                    Text2 = product.Price.ToString("C"),
                    ImageUrl = product.ImagePath
                };

                _lstTiles.Add(tile);
            }
        }
Exemplo n.º 2
0
        private XmlDocument CreateSquareTile (Tile tile)
        {
            // Create a live update for a square tile
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText02);

            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = tile.Text2;
            tileTextAttributes[1].InnerText = tile.Text1;   

            XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", tile.ImageUrl);
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "Contoso Electronics logo");

            var sqTileBinding = (XmlElement)tileXml.GetElementsByTagName("binding").Item(0);
            sqTileBinding.SetAttribute("branding", "none"); // removes logo from lower left-hand corner of tile

            return tileXml;
        }
Exemplo n.º 3
0
        private XmlDocument CreateWideTile (Tile tile)
        {
            // Create a live update for a wide tile
            XmlDocument wideTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText04);

            // Assign text
            XmlNodeList wideTileTextAttributes = wideTileXml.GetElementsByTagName("text");
            wideTileTextAttributes[0].AppendChild(wideTileXml.CreateTextNode(tile.Text2));
            wideTileTextAttributes[1].AppendChild(wideTileXml.CreateTextNode(tile.Text1));

            // Assign Image
            XmlNodeList wideTileImageAttributes = wideTileXml.GetElementsByTagName("image");
            ((XmlElement)wideTileImageAttributes[0]).SetAttribute("src", tile.ImageUrl);
            ((XmlElement)wideTileImageAttributes[0]).SetAttribute("alt", "Contoso Electronics logo");
                     
            return wideTileXml;
        }
Exemplo n.º 4
0
        private XmlDocument CreateLargeTile(Tile tile)
        {
            // Create a live update for a wide tile
            XmlDocument largeTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310ImageAndText01);

            XmlNodeList wideTileTextAttributes = largeTileXml.GetElementsByTagName("text");
            wideTileTextAttributes[0].AppendChild(largeTileXml.CreateTextNode(tile.Text1 + " "+tile.Text2));
            //wideTileTextAttributes[1].AppendChild(largeTileXml.CreateTextNode(tile.Text2));

            XmlNodeList wideTileImageAttributes = largeTileXml.GetElementsByTagName("image");
            ((XmlElement)wideTileImageAttributes[0]).SetAttribute("src", tile.ImageUrl);
            ((XmlElement)wideTileImageAttributes[0]).SetAttribute("alt", "Contoso Electronics logo");

            var wideTileBinding = (XmlElement)largeTileXml.GetElementsByTagName("binding").Item(0);
            wideTileBinding.SetAttribute("branding", "none"); // removes logo from lower left-hand corner of tile

            return largeTileXml;
        }