本文整理匯總了C#中Windows.UI.Xaml.Controls.Grid.FindName方法的典型用法代碼示例。如果您正苦於以下問題:C# Grid.FindName方法的具體用法?C# Grid.FindName怎麽用?C# Grid.FindName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.Controls.Grid
的用法示例。
在下文中一共展示了Grid.FindName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UpdateTileImagePrivate
private static async Task UpdateTileImagePrivate(Grid tileControl, SecondaryTile secondaryTile)
{
Action<string, string> assignText = (name, text) => ((TextBlock)tileControl.FindName(name)).Text = text;
Action<string> hide = (name) => ((TextBlock)tileControl.FindName(name)).Visibility = Visibility.Collapsed;
assignText("Timestamp", "Last update " + DateTime.Now.ToString("hh:mm:ss"));
Timetable timetable = null;
try
{
timetable = Timetable.ParseXml(await FileIO.ReadTextAsync(await
(await ApplicationData.Current.LocalFolder.GetFolderAsync("Timetables")).GetFileAsync(secondaryTile.Arguments)),
secondaryTile.Arguments, "");
var day = timetable.GetListedLessons(DateTime.Now, DateTime.Now.AddDays(7), ConvertHelpers.IsOddWeek(DateTime.Now))
.First(p => p.Value.Any(q => q.Value.Subject != Subject.None));
var lessonList = day.Value.Where(q => q.Value.Subject != Subject.None).Take(4).Select(p => new LessonData()
{
LessonTime = string.Format(Strings.LessonTimeMultiLineFormat, p.Key.Start, p.Key.End),
Subject = p.Value.Subject.Name,
Room = p.Value.Room
}).ToList();
if (day.Key.Date != DateTime.Today)
{
lessonList.Insert(0, new LessonData() { LessonTime = day.Key.Date.ToString("dddd") });
while (lessonList.Count > 4)
lessonList.RemoveAt(4);
}
((ItemsControl)tileControl.FindName("LessonsControl")).ItemsSource = lessonList;
var imageFileName = secondaryTile.Arguments + ".png";
var wideImageFileName = secondaryTile.Arguments + ".wide.png";
await RenderTile(tileControl, wideImageFileName, 310, 150);
tileControl.Width = tileControl.Height;
await RenderTile(tileControl, imageFileName, 150, 150);
secondaryTile.VisualElements.Square150x150Logo = new Uri("ms-appdata:///local/" + imageFileName);
secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appdata:///local/" + wideImageFileName);
secondaryTile.DisplayName = timetable.Name;
}
catch
{
secondaryTile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/Logo.scale-240.png");
secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.scale-240.png");
return;
}
}
示例2: PlaybackControl
public PlaybackControl(Grid grid)
{
PlaybackControlGrid = grid;
PlayPauseButton = PlaybackControlGrid.FindName("PlayPauseButtonOnLeft") as AppBarButton;
ShuffleButton = PlaybackControlGrid.FindName("ShuffleButton") as AppBarButton;
AlbumArtwork = PlaybackControlGrid.FindName("PlayBackImage") as Image;
TimeRemainingBlock = PlaybackControlGrid.FindName("TimeRemainingBlock") as TextBlock;
TimePastBlock = PlaybackControlGrid.FindName("TimeElapsedBlock") as TextBlock;
ProgressSlider = PlaybackControlGrid.FindName("ProgressSlider") as Slider;
}
示例3: loadFeedGrid
/// <summary>
/// 加載Grid中的Feed源
/// </summary>
/// <returns></returns>
private async Task loadFeedGrid(Grid feedGrid) {
ProgressRing progRing = (ProgressRing)feedGrid.FindName("prog");
TextBlock subTitle = (TextBlock)feedGrid.FindName("subTitle");
TextBlock description = (TextBlock)feedGrid.FindName("description");
TextBlock newNumText = (TextBlock)feedGrid.FindName("newNum");
progRing.Visibility = Visibility.Visible;
subTitle.Visibility = Visibility.Collapsed;
description.Visibility = Visibility.Collapsed;
var feed = (Feed)feedGrid.DataContext;
await FeedDataSource.getInstance().loadFeedAsync(feed);
Binding b = new Binding();
b.Mode = BindingMode.TwoWay;
b.Source = feed.Items.Count((i) => !i.IsRead);
newNumText.SetBinding(TextBlock.TextProperty, b);
progRing.Visibility = Visibility.Collapsed;
subTitle.Visibility = Visibility.Visible;
if (ApplicationView.Value != ApplicationViewState.Snapped) {
description.Visibility = Visibility.Visible;
}
}
示例4: Item_Tapped
private async void Item_Tapped(object sender, DoubleTappedRoutedEventArgs e)
{
item = sender as Grid;
ep = item.DataContext as Episode;
Image ima = item.FindName("ima") as Image;
if (ima.Opacity > 0.5)
{
if (!ep.Aired)
{
Helper.message("This episode hasn't aired yet. You cannot mark it as watched", "EPISODE NOT AIRED");
return;
}
if (await api.hasInternet())
{
await ep.markAsWatched();
await Memory.storeMostRecentQueueEpisode(q);
}
else
{
Memory.addCommand(new Command() { episode = ep, watched = true });
}
DoubleAnimation ani = new DoubleAnimation();
Storyboard.SetTarget(ani, ima);
Storyboard board = new Storyboard();
board.Completed += board_Completed;
Storyboard.SetTargetProperty(ani, "Opacity");
ani.To = 0.2;
ep.Opacity = 0.2;
board.Duration = new Duration(TimeSpan.FromSeconds(1));
board.Children.Add(ani);
ep.Seen = true;
board.Begin();
ep.OnPropertyChanged("redo");
}
else
{
item = sender as Grid;
ep = item.DataContext as Episode;
DoubleAnimation ani = new DoubleAnimation();
Storyboard.SetTarget(ani, ima);
Storyboard board = new Storyboard();
Storyboard.SetTargetProperty(ani, "Opacity");
ani.To = 0.9;
board.Duration = new Duration(TimeSpan.FromSeconds(1));
board.Children.Add(ani);
board.Begin();
ep.Seen = false;
ep.OnPropertyChanged("redo");
ep.OnPropertyChanged("Opacity");
if (await api.hasInternet())
{
await ep.markNotAsWatched();
}
else
{
Command com = new Command();
com.episode = ep;
com.watched = false;
Memory.addCommand(com);
}
}
//Update the last new queue item
await Memory.storeMostRecentQueueEpisode((queue.ItemsSource as Queue));
}
示例5: RefreshCruptedImageItem
private async Task RefreshCruptedImageItem(Grid iv)
{
var imageContent = iv.FindName("ImageContent") as Image;
var lvm = imageContent.DataContext as LineViewModel;
if (lvm == null) return;
var bitmap = imageContent.Source as BitmapImage;
if (bitmap == null) return;
var uri = bitmap.UriSource.AbsoluteUri;
if (uri.StartsWith("ms-appdata"))
{
var textContent = iv.FindName("TextContent") as TextBlock;
var commentIndicator = iv.FindName("CommentIndicator") as Rectangle;
var progressIndicator = iv.FindName("ProgressBar") as ProgressBar;
var imagePlaceholder = iv.FindName("ImagePlaceHolder") as Windows.UI.Xaml.Shapes.Path;
var remoteUri = lvm.Content;
textContent.Text = ImageLoadingTextPlaceholder;
imagePlaceholder.Visibility = Windows.UI.Xaml.Visibility.Visible;
imagePlaceholder.Opacity = 1;
imageContent.Visibility = Windows.UI.Xaml.Visibility.Visible;
textContent.TextAlignment = TextAlignment.Center;
textContent.Opacity = 1;
imageContent.Opacity = 0;
progressIndicator.Opacity = 1;
imageContent.ImageOpened -= imageContent_ImageOpened;
bitmap.DownloadProgress -= Image_DownloadProgress;
bitmap.UriSource = new Uri(remoteUri);
bitmap.DownloadProgress += Image_DownloadProgress;
imageContent.ImageOpened += imageContent_ImageOpened;
await CachedClient.DeleteIllustationAsync(remoteUri);
} // else is Network Issue
}
示例6: LoadItemIllustation
private void LoadItemIllustation(Grid iv, LineViewModel line)
{
var bitMap = new BitmapImage(line.ImageUri);
var imageContent = iv.FindName("ImageContent") as Image;
imageContent.DataContext = line;
var imagePlaceHolder = iv.FindName("ImagePlaceHolder") as Windows.UI.Xaml.Shapes.Path;
var progressIndicator = iv.FindName("ProgressBar") as ProgressBar;
bitMap.SetValue(BitmapLoadingIndicatorProperty, progressIndicator);
bitMap.DownloadProgress += Image_DownloadProgress;
imageContent.ImageOpened += imageContent_ImageOpened;
imageContent.ImageFailed += ImageContent_Failed;
imageContent.Source = bitMap;
}
示例7: FindOrCreateGridForLayout
private Grid FindOrCreateGridForLayout(Grid parent, string loc)
{
Tuple<int, int> quad;
int row = 0;
int col = 0;
var gridName = (parent == baseImpl.RootUI ? kGridName : parent.Name) + "_" + loc;
var pctl = (Grid)parent.FindName(gridName);
if (pctl == null)
{
quad = TranslateQLoc(loc);
row = quad.Item1;
col = quad.Item2;
var grid = new Grid();
grid.Name = gridName;
grid.HorizontalAlignment = HorizontalAlignment.Stretch;
grid.VerticalAlignment = VerticalAlignment.Stretch;
EnsureGrid(grid);
grid.SetValue(Grid.RowProperty, row);
grid.SetValue(Grid.ColumnProperty, col);
parent.Children.Add(grid);
pctl = grid;
}
return pctl;
}