private void HandleHeader(Point totalScrollPosition) { if (Header == null && HeaderTemplate == null) { return; } var headerHeight = HeaderMeasureHeight + totalScrollPosition.Y; if (headerHeight > 0) { if (totalScrollPosition.Y < 0) { HeaderHeight = new GridLength(HeaderMeasureHeight + totalScrollPosition.Y); _header.Margin = new Thickness(0, totalScrollPosition.Y, 0, 0); _header.Clip = new RectangleGeometry() { Rect = new Rect(0, -totalScrollPosition.Y, this.ActualWidth, HeaderMeasureHeight) }; } else { if (HeaderHeight != GridLength.Auto) { HeaderHeight = new GridLength(HeaderMeasureHeight); _header.Margin = new Thickness(0); _header.Clip = null; } } } else if (HasHeader()) { HeaderHeight = new GridLength(0); _header.Margin = new Thickness(0, -HeaderMeasureHeight, 0, 0); _header.Clip = new RectangleGeometry() { Rect = new Rect(0, HeaderMeasureHeight, this.ActualWidth, HeaderMeasureHeight) }; } }
public EditIdea() { this.InitializeComponent(); var bounds = Window.Current.Bounds; double height = bounds.Height; double width = bounds.Width; int int_width = (int)width; var grid_length_width = new Windows.UI.Xaml.GridLength(width, GridUnitType.Pixel); var half_grid_length_width = new Windows.UI.Xaml.GridLength(grid_length_width.Value / 2, GridUnitType.Pixel); MainScrollViewerGrid.ColumnDefinitions[0].Width = grid_length_width; MainScrollViewerGrid.ColumnDefinitions[1].Width = half_grid_length_width; if (App.Selected_Idea == null) { titleTxtBlock.Text = "new idea"; } else { titleTxtBlock.Text = App.Selected_Idea.Title; } }
public object Convert(object value, Type targetType, object parameter, string language) { GridLength gridLength = GridLength.Auto; double length = 200; double.TryParse(parameter as string, out length); if (value is bool) { gridLength = new GridLength((bool)value ? length : 0); } return gridLength; }
private void Page_SizeChanged(object sender, SizeChangedEventArgs e) { GridLength glAlign = new GridLength(e.NewSize.Width); if (this.ActualWidth < 720) { this.Left_Col.Width = glAlign; this.Right_Col.Width = glAlign; this.Right_Frame.SetValue(Grid.ColumnProperty, 0); } else { this.Left_Col.Width = new GridLength(2, GridUnitType.Star); this.Right_Col.Width = new GridLength(3, GridUnitType.Star); this.Right_Frame.SetValue(Grid.ColumnProperty, 2); } }
public bool Equals(GridLength gridLength) { return (this == gridLength); }
private void HandleFooter(Point value, Size sz, double totalRowsSize, bool hasMoreItems) { if (Footer == null && FooterTemplate == null) { return; } var maxV = totalRowsSize + HeaderMeasureHeight + _columnHeaderPanel.DesiredSize.Height - sz.Height; if ((maxV + value.Y) <= 0) { //if (value.Y < 0) { if (!hasMoreItems && FooterMeasureHeight == 0) { _footer.Measure(_contentGrid.DesiredSize); if (_footer.DesiredSize != Size.Empty && _footer.DesiredSize.Height != 0 && _footer.DesiredSize.Width != 0) { _verticalScrollBar.Maximum += _footer.DesiredSize.Height; } } var footHeight = -(maxV + value.Y); if (footHeight > 0 && FooterMeasureHeight > 0) { if (footHeight <= FooterMeasureHeight) { FooterHeight = new GridLength(footHeight); _footer.Margin = new Thickness(0, 0, 0, footHeight - FooterMeasureHeight); _footer.Clip = new RectangleGeometry() { Rect = new Rect(0, 0, this.ActualWidth, footHeight) }; if (!HasHeader()) { _cellPanel.footerHeight = footHeight; } } else { FooterHeight = new GridLength(FooterMeasureHeight); if (!HasHeader()) { _cellPanel.footerHeight = FooterMeasureHeight; } } } else if (HasFooter()) { FooterHeight = new GridLength(0); _footer.Margin = new Thickness(0, 0, 0, -FooterMeasureHeight); _footer.Clip = new RectangleGeometry() { Rect = new Rect(0, 0, this.ActualWidth, 0) }; if (!HasHeader()) { _cellPanel.footerHeight = 0; } } } } else { if (HasFooter()) { FooterHeight = new GridLength(0); _footer.Margin = new Thickness(0, 0, 0, -FooterMeasureHeight); _footer.Clip = new RectangleGeometry() { Rect = new Rect(0, 0, this.ActualWidth, 0) }; if (!HasHeader()) { _cellPanel.footerHeight = 0; } } } }
async void MainPage_Load(object sender, RoutedEventArgs e) { Files.Items.Clear(); //获取应用程序的本地存储文件NoteList StorageFolder storage = await ApplicationData.Current.LocalFolder.CreateFolderAsync("NoteList", CreationCollisionOption.OpenIfExists); //获取当前文件夹的文件 var files = await storage.GetFilesAsync(); { //便利 获取所有文件 foreach (StorageFile file in files) { //初始化一个Grid类 Grid a = new Grid(); //列的属性 ColumnDefinition col = new ColumnDefinition(); //宽度200 GridLength gl = new GridLength(200); col.Width = gl; //添加col a.ColumnDefinitions.Add(col); //定义第二列 ColumnDefinition col2 = new ColumnDefinition(); GridLength gl2 = new GridLength(100); col2.Width = gl2;////////////// a.ColumnDefinitions.Add(col2); //定义第三列 ColumnDefinition col3 = new ColumnDefinition(); GridLength g13 = new GridLength(100); col3.Width = g13; a.ColumnDefinitions.Add(col3); //添加一个TextBlock显示记事本名到第一列 TextBlock txbx = new TextBlock(); txbx.Text = file.DisplayName; txbx.FontSize = 20; //把txbx设置到Grid 0号位置 Grid.SetColumn(txbx, 0); //添加一个HyperlinkButton链接到记事本页面,这是第二列 //HyperlinkButton 可跳转Button HyperlinkButton btn = new HyperlinkButton(); btn.Width = 80; btn.Content = "删除"; btn.Foreground = new SolidColorBrush(Colors.Blue ); btn.FontSize = 20; btn.Name = file.DisplayName; //Lambda表达式 //事件添加一个Lambda表达式 //等价于下面btn_Click方法 btn.Click += (s ,ea) => { Frame.Navigate(typeof(DeleteItem ),file ); }; Grid.SetColumn(btn ,1); //添加一个HyperlinkButton链接到记事本页面,这是第三列 HyperlinkButton btn1 = new HyperlinkButton(); btn1.Width = 80; btn1.Content = "打开"; btn1.FontSize = 20; btn1.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); btn1.Name = file.DisplayName; btn1.Click += (s, ea) => { Frame.Navigate(typeof(AddItem), file); }; Grid.SetColumn(btn1, 2); //给Grid a 添加子元素 a.Children.Add(txbx); a.Children.Add(btn); a.Children.Add(btn1); //将 a 添加到Files中 Files.Items.Add(a); } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter is string) { HeaderGrid.Visibility = Visibility.Collapsed; var length = new GridLength(0); Root.RowDefinitions[0].Height = length; Root.RowDefinitions[1].Height = length; } else { Color c; SolidColorBrush s; if (Context.Theme == ElementTheme.Dark) { var d = this.Resources.ThemeDictionaries["Dark"] as ResourceDictionary; c = (Color)d["SystemBaseHighColor"]; s = (SolidColorBrush)d["SystemControlForegroundBaseHighBrush"]; } else if (Context.Theme == ElementTheme.Light) { var d = this.Resources.ThemeDictionaries["Light"] as ResourceDictionary; c = (Color)d["SystemBaseHighColor"]; s = (SolidColorBrush)d["SystemControlForegroundBaseHighBrush"]; } else { c = (Color)Resources["SystemBaseHighColor"]; s = (SolidColorBrush)Resources["SystemControlForegroundBaseHighBrush"]; } if (baba != null) baba.ChangeColor(Colors.Transparent, c, s); if (!license.IsPurchased) { RefreshButton.IsEnabled = false; } } }
public static void SetLength(DependencyObject obj, GridLength value) { obj.SetValue(LengthProperty, value); }
internal static void Add(this ColumnDefinitionCollection @this, GridLength length) { if (@this == null) throw new NullReferenceException("@this must not be null"); @this.Add(new ColumnDefinition { Width = length }); }
private void getNotebook(string a) { GridLength hleng = new GridLength(250); currtbook.Width = hleng; char[] charArray = a.ToCharArray(); string sub; string s_temp, s_full; string S_xinzhi; int i = 0, j = 0, k = 0, cnt = 0; int m = 0; ImageBrush brush = new ImageBrush(); ImageBrush brush1 = new ImageBrush(); brush.ImageSource = new BitmapImage( new Uri("ms-appx:///Assets/0006.jpg", UriKind.RelativeOrAbsolute) ); while (j != a.Length) { s_full = "\0"; for (i = j; charArray[i] != '&'; i++) { } sub = a.Substring(j + 2, i - j - 2); s_full = sub + '\n'; while (charArray[j] != 'E') { j = i + 2; k = k + 1; cnt = 0; switch (charArray[i + 1]) { case '1': S_xinzhi = "prop. "; break; case '2': S_xinzhi = "int. "; break; case '3': S_xinzhi = "abbr. "; break; case '4': S_xinzhi = "n. "; break; case '5': S_xinzhi = "v. "; break; case '6': S_xinzhi = "adj. "; break; case '7': S_xinzhi = "pron. "; break; case '8': S_xinzhi = "art. "; break; case '9': S_xinzhi = "na. "; break; default: S_xinzhi = "more. "; break; } s_temp = S_xinzhi; s_full = s_full + S_xinzhi; for (i = j; charArray[i] != '&'; i++) { if (charArray[i] == '$' && charArray[i + 1] == '$') { sub = a.Substring(j, i - j); i = i + 1; j = i + 1; cnt = cnt + 1; if (cnt <= 4) { s_temp = s_temp + sub + ';'; } s_full = s_full + sub + ';'; if (cnt == 38) break; } if (charArray[i] == 'E') break; } if (cnt == 38) { while (charArray[j] < '0' || charArray[j] > '9') { if (charArray[j] == 'E') break; j++; } i = j; if (charArray[j] == 'E') break; } else { sub = a.Substring(j, i - j); cnt = cnt + 1; if (cnt <= 4) s_temp = s_temp + sub + ';'; s_full = s_full + sub + ';'; if (charArray[i] == 'E') break; } s_full = s_full + '\n'; } j = i + 1; Grid g = new Grid(); Button close = new Button(); TextBlock h = new TextBlock(); g.Margin = new Thickness(12, 12, 12, 12); g.Background = brush; h.Width = 200; h.Height = 150; h.TextWrapping = TextWrapping.Wrap; h.Text = s_full; g.Children.Add(h); close.Content = "------"; close.Name = "name" + m; g.Name = "name" + m; close.HorizontalAlignment = HorizontalAlignment.Right; close.VerticalAlignment = VerticalAlignment.Top; close.Height = 25; close.Click += Closeunit_Click; close.Background = brush1; g.Children.Add(close); currentNotebook.Children.Add(g); m = m + 1; } }
private void Like_Click(object sender, RoutedEventArgs e) { if (flag_notebook == false) { Task.Run(() => { ImportWordList1(); }); while (bgetword1 == false) ; bgetword1 = false; string a = ""; for (int i = 0; i < Wordlist1.Length; i++) { a += Wordlist1[i]; } //string a = "01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01词语 音标&4释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E01word pron&1释义$$一个很长的释义$$一个很长长长长长长长长长长长长长长长长的释义&5释义E"; getNotebook(a); flag_notebook = true; } else { currentNotebook.Children.Clear(); flag_notebook = false; GridLength hleng = new GridLength(0); currtbook.Width = hleng; } }
private void layoutRoot_Loaded(object sender, RoutedEventArgs e) { FavouritesHeight = new GridLength(root.ActualHeight - 200); }
UIElement BuildPage(int pageNumber) { // Account for pages going 1..N rather than 0..N-1 int pageIndex = pageNumber - 1; Grid parentGrid = new Grid(); parentGrid.Width = this.pageSize.Value.Width; parentGrid.Height = this.pageSize.Value.Height; // Make a grid Grid grid = new Grid(); grid.Margin = new Thickness(100, 20, 100, 50); // Make grid rows and cols GridLength length = new GridLength(1, GridUnitType.Star); parentGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); parentGrid.RowDefinitions.Add(new RowDefinition() { Height = length }); parentGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = length }); for (int i = 0; i < RowCount; i++) { grid.RowDefinitions.Add(new RowDefinition() { Height = length }); } for (int i = 0; i < ColCount; i++) { if (i % 2 == 0) { grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(80) }); } else { grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = length }); } } // Make items TextBlock pageTitle = new TextBlock(); pageTitle.Text = "Tasks for " + DateTime.Now.ToString("MM/dd/yyyy"); pageTitle.Margin = new Thickness(100, 50, 100, 20); pageTitle.FontSize = 30; Grid.SetRow(pageTitle, 0); Grid.SetColumn(pageTitle, 0); parentGrid.Children.Add(pageTitle); var tasks = TaskRepository.Tasks.AsQueryable() .OrderBy(t => t.Start) .Where(t => t.Start >= DateTime.Now && t.Start < DateTime.Today.AddDays(1)) .Take(10); int rowNumber = 0; foreach (TaskModel task in tasks) { TextBlock timeText = new TextBlock(); timeText.Text = task.Start.ToString("t"); timeText.FontSize = 20; Grid.SetRow(timeText, rowNumber); Grid.SetColumn(timeText, 0); TextBlock titleText = new TextBlock(); titleText.Text = task.Title; titleText.FontSize = 20; titleText.TextWrapping = TextWrapping.Wrap; Grid.SetRow(titleText, rowNumber); Grid.SetColumn(titleText, 1); rowNumber++; grid.Children.Add(timeText); grid.Children.Add(titleText); } // Offset it into the printable area Canvas.SetLeft(grid, this.imageableRect.Value.Left); Canvas.SetTop(grid, this.imageableRect.Value.Top); Grid.SetRow(grid, 1); Grid.SetColumn(grid, 0); parentGrid.Children.Add(grid); return (parentGrid); }
private void DetailsPanelGotoWideState() { DetailsPanelIsNormalState = false; var length = new GridLength(1, GridUnitType.Star); Column2.Width = length; UIHelper.Change_Row_Column(DetailGrid2, 0, 2); UIHelper.Change_Row_Column(DetailGrid3, 1, 0); UIHelper.Change_Row_Column(DetailGrid4, 1, 1); UIHelper.Change_Row_Column(DetailGrid5, 1, 2); UIHelper.Change_Row_Column(DetailGrid6, 2, 0); UIHelper.Change_Row_Column(DetailGrid7, 2, 1); UIHelper.Change_Row_Column(DetailGrid8, 2, 2); UIHelper.ReverseVisibility(DetailGrid8); }
private void OnLoaded(object sender, RoutedEventArgs e) { var GridViewWidth = itemGridView.ActualWidth; var grid_length_width = new Windows.UI.Xaml.GridLength(GridViewWidth, GridUnitType.Pixel); //ContentGrid.ColumnDefinitions[0].Width = grid_length_width; }
public object Convert(object value, Type targetType, object parameter, string language) { int w = (int)value; GridLength l = new GridLength(w, GridUnitType.Star); return l; }