当前位置: 首页>>代码示例>>C#>>正文


C# TextBlock.SetValue方法代码示例

本文整理汇总了C#中TextBlock.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.SetValue方法的具体用法?C# TextBlock.SetValue怎么用?C# TextBlock.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextBlock的用法示例。


在下文中一共展示了TextBlock.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MarkdownList

 public MarkdownList(bool numbered, IEnumerable<UIElement> elements)
 {
     InitializeComponent();
     int number = 1;
     int rowCount = 0;
     foreach (var element in elements)
     {
         theGrid.RowDefinitions.Add(new RowDefinition());
         var text = new TextBlock { TextWrapping = System.Windows.TextWrapping.Wrap, Margin = new Thickness(5, 0, 15, 0), Text = numbered ? (number++).ToString() + "." : "\u25CF" };
         text.SetValue(Grid.RowProperty, rowCount);
         text.SetValue(Grid.ColumnProperty, 0);
         element.SetValue(Grid.RowProperty, rowCount++);
         element.SetValue(Grid.ColumnProperty, 1);
         if (element is RichTextBox)
         {
             element.SetValue(FrameworkElement.MarginProperty, new Thickness(-8, 0, 0, 0));
         }
         else
         {
             element.SetValue(FrameworkElement.MarginProperty, new Thickness(4, 0, 0, 0));
         }
         theGrid.Children.Add(text);
         theGrid.Children.Add(element);
     }
 }
开发者ID:Synergex,项目名称:Baconography,代码行数:25,代码来源:MarkdownList.xaml.cs

示例2: fachpicker_SelectionChanged

 private void fachpicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     Fach f = fachpicker.SelectedItem as Fach;
     if (f.lektion == Lektion.Anderes && f.customfach == null)
     {
         if (fächeradded) { }
         else
         {
             //benutzerdefiniertes Fach
             fächer = new TextBlock() { Text = "Fach: ", FontSize = 34, Margin = new Thickness(7,0,0,0) };
             fächer.SetValue(Grid.RowProperty, 1);
             fächer2 = new TextBox();
             fächer2.SetValue(Grid.RowProperty, 1);
             fächer2.SetValue(Grid.ColumnProperty, 1);
             ContentPanel.Children.Add(fächer);
             ContentPanel.Children.Add(fächer2);
             fächeradded = true;
         }
     }
     else
     {
         Lehrperson.Text = f.Lehrer;
         Farbe.SelectedIndex = f.color;
         if (fächeradded)
         {
             ContentPanel.Children.Remove(fächer);
             ContentPanel.Children.Remove(fächer2);
             fächeradded = false;
         }
     }
 }
开发者ID:famoser,项目名称:Gymoberwil,代码行数:31,代码来源:Fachbearbeiten.xaml.cs

示例3: OnDownloaded

        private void OnDownloaded(object sender, DownloadStringCompletedEventArgs args)
        {
            entradas = parse(args.Result);

            for (int j = 1, i = entradas.Count - 5; i < entradas.Count; i++)
            {
                if (i < 0)
                    continue;

                TextBlock emprestimoBlock = new TextBlock();
                TextBlock nameBlock = new TextBlock();
                TextBlock devolucaoBlock = new TextBlock();

                emprestimoBlock.SetValue(Grid.ColumnProperty, 0);
                nameBlock.SetValue(Grid.ColumnProperty, 1);
                devolucaoBlock.SetValue(Grid.ColumnProperty, 2);

                emprestimoBlock.SetValue(Grid.RowProperty, j);
                nameBlock.SetValue(Grid.RowProperty, j);
                devolucaoBlock.SetValue(Grid.RowProperty, j);

                emprestimoBlock.HorizontalAlignment = HorizontalAlignment.Center;
                nameBlock.HorizontalAlignment = HorizontalAlignment.Center;
                devolucaoBlock.HorizontalAlignment = HorizontalAlignment.Center;

                emprestimoBlock.VerticalAlignment = VerticalAlignment.Center;
                nameBlock.VerticalAlignment = VerticalAlignment.Center;
                devolucaoBlock.VerticalAlignment = VerticalAlignment.Center;

                emprestimoBlock.Text = entradas[i].emprestimo;
                nameBlock.Text = entradas[i].nome;
                devolucaoBlock.Text = entradas[i].devolucao;

                nameBlock.TextAlignment = TextAlignment.Center;
                nameBlock.FontStyle = FontStyles.Italic;

                ContentPanel.Children.Add(emprestimoBlock);
                ContentPanel.Children.Add(nameBlock);
                ContentPanel.Children.Add(devolucaoBlock);

                j++;
            }
        }
开发者ID:vyrp,项目名称:cerberus,代码行数:43,代码来源:EmprestimosTabela.xaml.cs

示例4: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Set the data context of the listbox control to the sample data
            DataContext = App.ViewModel;

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
            foreach (var month in _monthsList)
            {
                var textBlock = new TextBlock { Text = month };
                textBlock.SetValue(AutomationProperties.NameProperty, month);

                // ReSharper disable once PossibleNullReferenceException
                this.ListBox.Items.Add(textBlock);
            }
        }
开发者ID:sleekweasel,项目名称:winphonedriver,代码行数:19,代码来源:MainPage.xaml.cs

示例5: InitializeBusyIndicator

        partial void InitializeBusyIndicator()
        {
            if (_busyIndicator != null)
            {
                return;
            }

            _grid = new Grid();
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)});
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)});
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)});
            _grid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(1, GridUnitType.Star)});

            var backgroundBorder = new Border();
            backgroundBorder.Background = new SolidColorBrush(Colors.Gray);
            backgroundBorder.Opacity = 0.5;
            backgroundBorder.SetValue(Grid.RowSpanProperty, 4);
            _grid.Children.Add(backgroundBorder);

            _statusTextBlock = new TextBlock();
            //_statusTextBlock.Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"];
            _statusTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            _statusTextBlock.SetValue(Grid.RowProperty, 1);
            _grid.Children.Add(_statusTextBlock);

            _busyIndicator = ConstructorBusyIndicator();
            _busyIndicator.SetValue(Grid.RowProperty, 2);
            _grid.Children.Add(_busyIndicator);

            _containerPopup = new Popup();
            _containerPopup.VerticalAlignment = VerticalAlignment.Center;
            _containerPopup.HorizontalAlignment = HorizontalAlignment.Center;
            _containerPopup.Child = _grid;

            double rootWidth = Window.Current.Bounds.Width;
            double rootHeight = Window.Current.Bounds.Height;

            _busyIndicator.Width = rootWidth;

            _grid.Width = rootWidth;
            _grid.Height = rootHeight;

            _containerPopup.UpdateLayout();
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:44,代码来源:PleaseWaitService.winrt.cs

示例6: SetCollapseOnEmpty

 public static void SetCollapseOnEmpty(TextBlock element, bool value)
 {
     element.SetValue(CollapseOnEmptyProperty, value);
 }
开发者ID:jarkkom,项目名称:awfuldotnet,代码行数:4,代码来源:UIExtensions.cs

示例7: SetHideOnNullOrEmpty

 public static void SetHideOnNullOrEmpty(TextBlock element, bool value)
 {
     element.SetValue(HideOnNullOrEmptyProperty, value);
 }
开发者ID:jarkkom,项目名称:awfuldotnet,代码行数:4,代码来源:UIExtensions.cs

示例8: fachpicker_SelectionChanged

 private void fachpicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (fachpicker.SelectedIndex == 0)
     {
         //frei
         Zimmernummer.IsEnabled = false;
         Lehrperson.IsEnabled = false;
         Lehrperson.Text = "";
         Fach f = fachpicker.SelectedItem as Fach;
         try
         {
             Farbe.SelectedIndex = f.color;
         }
         catch { }
         if (fächeradded)
         {
             ContentPanel.Children.Remove(fächer);
             ContentPanel.Children.Remove(fächer2);
             fächeradded = false;
         }
     }
     else
     {
         Zimmernummer.IsEnabled = true;
         Lehrperson.IsEnabled = true;
         if (fachpicker.SelectedIndex == fachpicker.Items.Count - 1)
         {
             if (fächeradded) { }
             else
             {
                 Zimmernummer.Text = "";
                 Lehrperson.Text = "";
                 //benutzerdefiniertes Fach
                 fächer = new TextBlock() { Text = "Fach: ", FontSize = 34, Margin = new Thickness(7, 0, 0, 0) };
                 fächer.SetValue(Grid.RowProperty, 3);
                 fächer2 = new TextBox();
                 fächer2.SetValue(Grid.RowProperty, 3);
                 fächer2.SetValue(Grid.ColumnProperty, 1);
                 ContentPanel.Children.Add(fächer);
                 ContentPanel.Children.Add(fächer2);
                 Lehrperson.Text = "";
                 fächeradded = true;
             }
         }
         else
         {
             Fach f = fachpicker.SelectedItem as Fach;
             Lehrperson.Text = f.Lehrer;
             Farbe.SelectedIndex = f.color;
             if (fächeradded)
             {
                 ContentPanel.Children.Remove(fächer);
                 ContentPanel.Children.Remove(fächer2);
                 fächeradded = false;
             }
         }
     }
 }
开发者ID:famoser,项目名称:Gymoberwil,代码行数:58,代码来源:Stundeerstellen.xaml.cs

示例9: InitGrid

        private void InitGrid()
        {
            Trip monTrip;
            RowDefinition tmpRow;
            double tpsTot=0;
            if (m != null)
            {
                for (int i = 0; i < m.Count; i++)
                {
                    monTrip =myRoadM.Trips.Where(o => o.Start.Equals(m[i])).FirstOrDefault();
                    
                    if (monTrip != null  && !m[i].IsLocationFail)
                    {
                        if (i == 0)
                        {
                            tmpRow = new RowDefinition();
                            tmpRow.Height = GridLength.Auto;
                            gr_InfoRD.RowDefinitions.Add(tmpRow);
                            flbI_InfoRdv = new FlecheBasInfo();
                            flbI_InfoRdv.SujetRdv = "Départ";
                            flbI_InfoRdv.AdrRdv = m[i].City;
                            flbI_InfoRdv.Distance = monTrip.Distance + " km";
                            flbI_InfoRdv.TpsTrajet = monTrip.Duration + " min";
                            tpsTot = tpsTot + monTrip.Duration;
                            flbI_InfoRdv.ConSomation = Math.Round(((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100), 2) + " L";
                            flbI_InfoRdv.Cout =Math.Round((((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]),2) + " €";
                            flbI_InfoRdv.IsTripFail1 = monTrip.IsTripFail;
                            flbI_InfoRdv.InitInfo();
                            //flbI_InfoRdv.Margin = new Thickness(1, 1, 1, 1);
                            flbI_InfoRdv.SetValue(Grid.RowProperty, i);
                            flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5);
                            gr_InfoRD.Children.Add(flbI_InfoRdv);
                            continue;
                        }
                        tmpRow = new RowDefinition();
                        tmpRow.Height = GridLength.Auto;
                        gr_InfoRD.RowDefinitions.Add(tmpRow);
                        flbI_InfoRdv = new FlecheBasInfo();
                        flbI_InfoRdv.SujetRdv = m[i].Subject+" ("+m[i].DateTime.ToShortTimeString()+")";
                        flbI_InfoRdv.AdrRdv = m[i].Address;
                        flbI_InfoRdv.Distance = monTrip.Distance + " km";
                        flbI_InfoRdv.TpsTrajet = monTrip.Duration + " min";
                        tpsTot = tpsTot + monTrip.Duration;
                        flbI_InfoRdv.IsTripFail1 = monTrip.IsTripFail;
                        flbI_InfoRdv.ConSomation = Math.Round(((monTrip.Distance * (double)settings["ConsoCarburant"])/100),2) + " L";
                        flbI_InfoRdv.Cout = Math.Round((((monTrip.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]), 2) + " €";
                        flbI_InfoRdv.InitInfo();                        
                        flbI_InfoRdv.SetValue(Grid.RowProperty, i);
                        flbI_InfoRdv.Margin = new Thickness(1, 5, 1, 5);
                        gr_InfoRD.Children.Add(flbI_InfoRdv);

                    }
                    if (i == m.Count - 1)
                    {

                        var monTxt = new TextBlock();
                        tmpRow = new RowDefinition();
                        tmpRow.Height = GridLength.Auto;
                        gr_InfoRD.RowDefinitions.Add(tmpRow);
                        monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                        monTxt.SetValue(Grid.RowProperty, i);
                        monTxt.Text = "Arrivée";
                        System.Windows.Shapes.Rectangle monRect = new System.Windows.Shapes.Rectangle();
                        monRect.Height = 45;
                        monRect.Width = 340;
                        monRect.SetValue(Grid.RowProperty, i);
                        monRect.SetValue(System.Windows.Shapes.Rectangle.FillProperty, App.Current.Resources["PhoneAccentBrush"]);
                        gr_InfoRD.Children.Add(monRect);
                        gr_InfoRD.Children.Add(monTxt);
                        monTxt = new TextBlock();
                        tmpRow = new RowDefinition();
                        tmpRow.Height = GridLength.Auto;
                        gr_InfoRD.RowDefinitions.Add(tmpRow);
                        monTxt.SetValue(Grid.RowProperty, i+2);
                        monTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                        monTxt.Text = m[i].City;
                        monTxt.FontSize = 18.75;
                        monTxt.FontFamily = new System.Windows.Media.FontFamily("Segoe UI Light");
                        gr_InfoRD.Children.Add(monTxt);
                    }

                }
                rt_ConsoTrajet.tb_info2.Text = Math.Round(((myRoadM.Distance * (double)settings["ConsoCarburant"]) / 100), 2) + " L"; ;
                rt_CoutTot.tb_info2.Text = Math.Round((((myRoadM.Distance * (double)settings["ConsoCarburant"]) / 100) * (double)settings["PrixCarburant"]), 2) + " €"; ;
                rt_DistRdv.tb_info2.Text = myRoadM.Distance+"km";
                rt_nbrRdv.tb_info2.Text = myRoadM.Meetings.Count-2+"";
                rt_TpsTrajetRdv.tb_info2.Text =tpsTot+" min";
               

            }
            initRdvOpti();
            indicator.IsIndeterminate = false;
            indicator.IsVisible = false;
        }
开发者ID:BenJoyenConseil,项目名称:planmyway,代码行数:94,代码来源:PivotRoadTrip.xaml.cs

示例10: ClearGraph

 /// <summary>
 /// Draw an empty graph with "No data to display" text
 /// </summary>
 private void ClearGraph()
 {
     leftBorder.Children.Clear();
     bottomBorder.Children.Clear();
     graphArea.Children.Clear();
     TextBlock noData = new TextBlock()
     {
         Text = "No data to display"
     };
     double width  = noData.ActualWidth;
     double height = noData.ActualHeight;
     if (width < graphWidth && height < graphHeight)
     {
         noData.SetValue(Canvas.LeftProperty, (double)(graphWidth  / 2 - width /  2) - rootElement.ColumnDefinitions[0].Width.Value / 2);
         noData.SetValue(Canvas.TopProperty,  (double)(graphHeight / 2 - height / 2) + rootElement.RowDefinitions[2].Height.Value   / 2);
         graphArea.Children.Add(noData);
     }
 }
开发者ID:Esri,项目名称:arcgis-samples-winphone,代码行数:21,代码来源:Graph.xaml.cs

示例11: InitPopup

        private void InitPopup()
        {
            popup = new Popup();
            popup.Opened += popup_Opened;

            Binding backgroundBinding = new Binding("Background");
            backgroundBinding.Source = this;

            Binding foregroundBinding = new Binding("Foreground");
            foregroundBinding.Source = this;

            Grid border = new Grid();
            border.Background = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0));
            border.Width = Application.Current.Host.Content.ActualWidth;
            border.Height = Application.Current.Host.Content.ActualHeight;

            Grid container = new Grid();
            CompositeTransform transform = new CompositeTransform()
            {
                TranslateY = -Application.Current.Host.Content.ActualHeight
            };
            container.RenderTransform = transform;
            container.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            container.SetBinding(Grid.BackgroundProperty, backgroundBinding);

            #region init grid rows

            RowDefinition row1 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            container.RowDefinitions.Add(row1);

            RowDefinition row2 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            container.RowDefinitions.Add(row2);

            RowDefinition row3 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            container.RowDefinitions.Add(row3);

            #endregion

            TextBlock title = new TextBlock()
            {
                Margin = new Thickness(12),
                FontSize = 30,
                FontWeight = FontWeights.Black
            };
            Binding titleBinding = new Binding("Title");
            titleBinding.Source = this;
            title.SetBinding(TextBlock.TextProperty, titleBinding);

            title.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
            container.Children.Add(title);

            TextBlock content = new TextBlock()
            {
                Margin = new Thickness(12),
                FontSize = 26,
                FontWeight = FontWeights.Medium
            };

            Binding contentBinding = new Binding("Content");
            contentBinding.Source = this;
            content.SetBinding(TextBlock.TextProperty, contentBinding);

            content.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
            content.SetValue(Grid.RowProperty, 1);
            container.Children.Add(content);

            switch (MessageBoxButtons)
            {
                case MessageBoxButton.OK:
                    {
                        Button btn = new Button()
                        {
                            Content = "OK",
                            Margin = new Thickness(0, 0, 0, 10)
                        };

                        btn.Click += (s, args) =>
                        {
                            var handler = OKClick;
                            if (null != handler)
                            {
                                handler(this, new RoutedEventArgs());
                            }

                            GetCloseAnimation();
                        };

                        btn.SetValue(Grid.RowProperty, 2);
                        container.Children.Add(btn);
                    }
                    break;
//.........这里部分代码省略.........
开发者ID:kjiwu,项目名称:WP_CustomControls,代码行数:101,代码来源:MyMessageBox.cs

示例12: RenderViewItem

        private void RenderViewItem(Item item)
        {
            // get the item type
            ItemType itemType = null;
            if (ItemType.ItemTypes.TryGetValue(item.ItemTypeID, out itemType) == false)
                return;

            // create a list of all the first subitems in each of the sublists of the item (e.g. Contacts, Places, etc)
            var subLists = App.ViewModel.Items.Where(i => i.ParentID == item.ID && i.IsList == true).ToList();
            var subItems = new List<Item>();
            foreach (var subList in subLists)
            {
                var itemRef = App.ViewModel.Items.FirstOrDefault(i => i.ParentID == subList.ID && i.ItemTypeID == SystemItemTypes.Reference);
                if (itemRef != null)
                {
                    var target = App.ViewModel.Items.FirstOrDefault(i => i.ID == itemRef.ItemRef);
                    if (target != null)
                        subItems.Add(target);
                }
            }

            // render fields
            int row = 0;
            foreach (ActionType action in App.ViewModel.Constants.ActionTypes.OrderBy(a => a.SortOrder))
            {
                FieldValue fieldValue = item.FieldValues.FirstOrDefault(fv => fv.FieldName == action.FieldName);
                if (fieldValue == null)
                {
                    bool found = false;
                    foreach (var i in subItems)
                    {
                        fieldValue = i.FieldValues.FirstOrDefault(fv => fv.FieldName == action.FieldName);
                        if (fieldValue != null)
                        {
                            found = true;
                            break;
                        }
                    }

                    // if fieldvalue isn't found on this item or other subitems, don't process the action
                    if (found == false)
                        continue;
                }

                // get the value of the property
                string currentValue = fieldValue.Value;

                // for our purposes, an empty value is the same as null
                if (currentValue == "")
                    currentValue = null;

                // render this property if it's not null/empty
                if (currentValue != null)
                {
                    // first make sure that we do want to render (type-specific logic goes here)
                    switch (action.ActionName)
                    {
                        case "Postpone":
                            // if the date is already further in the future than today, omit adding this action
                            if (Convert.ToDateTime(currentValue).Date > DateTime.Today.Date)
                                continue;
                            break;
                    }

                    // add a new row
                    ViewGrid.RowDefinitions.Add(new RowDefinition() { MaxHeight = 72 });
                    Thickness margin = new Thickness(12, 20, 0, 0);  // bounding rectangle of padding

                    // create a new buton for the action (verb)
                    var button = new Button()
                    {
                        Content = action.DisplayName,
                        MinWidth = 200
                    };
                    button.SetValue(Grid.ColumnProperty, 0);
                    button.SetValue(Grid.RowProperty, row);
                    ViewGrid.Children.Add(button);

                    // create a label which holds the noun the verb will act upon
                    // usually extracted from the item field's contents
                    var valueTextBlock = new TextBlock()
                    {
                        DataContext = fieldValue,
                        Style = (Style)App.Current.Resources["PhoneTextNormalStyle"],
                        Margin = margin,
                    };

                    //value.SetBinding(TextBlock.TextProperty, new Binding(pi.Name));
                    valueTextBlock.SetValue(Grid.ColumnProperty, 1);
                    valueTextBlock.SetValue(Grid.RowProperty, row++);
                    ViewGrid.Children.Add(valueTextBlock);

                    // render the action based on the action type
                    switch (action.ActionName)
                    {
                        case ActionNames.Navigate:
                            try
                            {
                                Item targetList = App.ViewModel.Items.Single(i => i.ID == Guid.Parse(currentValue));
                                //valueTextBlock.Text = String.Format("to {0}", targetList.Name);
//.........这里部分代码省略.........
开发者ID:ogazitt,项目名称:zaplify,代码行数:101,代码来源:ItemPage.xaml.cs

示例13: displayEventList

        private void displayEventList(List<Event> events, bool noStartHour, bool noEndhour)
        {
            // if the event last all day, only 1 iteration
            int _maxHour = (noStartHour && noEndhour) ? 1 : 24;

            // display the events that starts and ends at the selected date
            for (int i = 0; i < _maxHour; i++)
            {
                foreach (Event e in events)
                {

                    int _startHour = noStartHour ? 0 :Int32.Parse(e.Start.DateTime.Substring(11, 2));
                    int _endHour = noEndhour ? 0 : Int32.Parse(e.End.DateTime.Substring(11, 2));

                    if (_startHour == i)
                    {
                        // filling the tab of the day cal with the current event
                        int k = 0;
                        while (eventTabFill[i, k] != false)
                        {
                            k++;
                        }

                        int _nbHour = _endHour == 00 ? 24 - _startHour : _endHour - _startHour;
                        for (int j = 0; j < _nbHour; j++)
                        {
                            eventTabFill[i + j, k] = true;
                        }

                        // getting R G B from the colorID of the event
                        string _eventColor = calendar.getEventColorById(e.ColorId != null ? e.ColorId : "1").Background;
                        int _red = Int32.Parse(_eventColor.Substring(1, 2), NumberStyles.AllowHexSpecifier);
                        int _green = Int32.Parse(_eventColor.Substring(3, 2), NumberStyles.AllowHexSpecifier);
                        int _blue = Int32.Parse(_eventColor.Substring(5, 2), NumberStyles.AllowHexSpecifier);

                        // creating a rectangle colored with the event's color
                        if (_nbHour > 12)
                        {
                            Rectangle _rect = new Rectangle();
                            _rect.Height = 12 * 100;
                            _rect.Width = 10;
                            _rect.SetValue(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0])));
                            _rect.Visibility = Visibility.Visible;
                            _rect.Margin = new Thickness((k * eventWidth), i * 100, 0, 0);
                            _rect.VerticalAlignment = VerticalAlignment.Top;
                            _rect.HorizontalAlignment = HorizontalAlignment.Left;

                            Rectangle _rect2 = new Rectangle();
                            _rect2.Height = (_nbHour - 12) * 100;
                            _rect2.Width = 10;
                            _rect2.SetValue(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0])));
                            _rect2.Visibility = Visibility.Visible;
                            _rect2.Margin = new Thickness((k * eventWidth), i * 100 + 1200, 0, 0);
                            _rect2.VerticalAlignment = VerticalAlignment.Top;
                            _rect2.HorizontalAlignment = HorizontalAlignment.Left;
                            Events.Children.Add(_rect);
                            Events.Children.Add(_rect2);
                        }
                        else
                        {
                            Rectangle _rect = new Rectangle();
                            _rect.Height = _nbHour == 0 ? 30 : _nbHour * 100;
                            _rect.Width = 10;
                            _rect.SetValue(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0])));
                            _rect.Visibility = Visibility.Visible;
                            _rect.Margin = new Thickness((k * eventWidth), i * 100, 0, 0);
                            _rect.VerticalAlignment = VerticalAlignment.Top;
                            _rect.HorizontalAlignment = HorizontalAlignment.Left;
                            Events.Children.Add(_rect);
                        }

                        // creating the textblock for the title of the event (clickable) colored with the event's color
                        TextBlock _title = new TextBlock();
                        _title.DataContext = e;
                        _title.SetBinding(TextBlock.TextProperty, new Binding("Summary"));
                        _title.SetValue(TextBlock.ForegroundProperty, new SolidColorBrush(Color.FromArgb((BitConverter.GetBytes(255))[0], (BitConverter.GetBytes(_red))[0], (BitConverter.GetBytes(_green))[0], (BitConverter.GetBytes(_blue))[0])));
                        _title.Height = 30;
                        _title.Width = eventWidth - 10;
                        _title.Margin = new Thickness((k * eventWidth) + 13, i * 100 + 3, 3, 3);
                        _title.VerticalAlignment = VerticalAlignment.Top;
                        _title.HorizontalAlignment = HorizontalAlignment.Left;
                        _title.TextWrapping = TextWrapping.Wrap;
                        _title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);

                        // creating the textblock for the description of the event
                        TextBlock _desc = new TextBlock();
                        _desc.DataContext = e;
                        _desc.SetBinding(TextBlock.TextProperty, new Binding("Description"));
                        _desc.Height = _nbHour == 0 ? 30 : 70 + ((_nbHour - 1) * 100);
                        _desc.Width = eventWidth - 10;
                        _desc.Margin = new Thickness((k * eventWidth) + 13, (i * 100) + 33, 3, 3);
                        _desc.VerticalAlignment = VerticalAlignment.Top;
                        _desc.HorizontalAlignment = HorizontalAlignment.Left;
                        _desc.TextWrapping = TextWrapping.Wrap;

                        Events.Children.Add(_title);
                        Events.Children.Add(_desc);

                    }
                }
//.........这里部分代码省略.........
开发者ID:pokpatrick,项目名称:PhoneApp,代码行数:101,代码来源:DayEvent.xaml.cs

示例14: InitPopup

        private void InitPopup()
        {
            Binding fontSizeBinding = new Binding("FontSize");
            fontSizeBinding.Source = this;

            Binding fontWeightBinding = new Binding("FontWeight");
            fontWeightBinding.Source = this;

            Binding foregroundBinding = new Binding("Foreground");
            foregroundBinding.Source = this;

            popup = new Popup();
            popup.VerticalOffset = SystemTray.IsVisible ? 30 : 0;

            Grid grid = new Grid();
            grid.MinHeight = MinHeight;
            grid.Width = Application.Current.Host.Content.ActualWidth;
            PlaneProjection projection = new PlaneProjection()
            {
                RotationX = -90
            };
            grid.Projection = projection;

            Binding backBinding = new Binding("Background");
            backBinding.Source = this;
            grid.SetBinding(Grid.BackgroundProperty, backBinding);

            ColumnDefinition col1 = new ColumnDefinition()
            {
                Width = GridLength.Auto
            };
            ColumnDefinition col2 = new ColumnDefinition()
            {
                Width = GridLength.Auto
            };
            ColumnDefinition col3 = new ColumnDefinition();

            grid.ColumnDefinitions.Add(col1);
            grid.ColumnDefinitions.Add(col2);
            grid.ColumnDefinitions.Add(col3);

            Image imgIcon = new Image();
            imgIcon.Margin = new Thickness(4);
            Binding imgBinding = new Binding("Icon");
            imgBinding.Source = this;

            var imageMaxWidthBinding = new Binding("MinHeight");
            imageMaxWidthBinding.Source = this;
            imgIcon.SetBinding(Image.MaxWidthProperty, imageMaxWidthBinding);
            imgIcon.Stretch = Stretch.Fill;
            imgIcon.SetBinding(Image.SourceProperty, imgBinding);
            grid.Children.Add(imgIcon);

            TextBlock tbkTitle = new TextBlock();
            tbkTitle.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            tbkTitle.Margin = new Thickness(4);
            Binding titleBinding = new Binding("Title");
            titleBinding.Source = this;
            tbkTitle.SetBinding(TextBlock.TextProperty, titleBinding);
            tbkTitle.SetBinding(TextBlock.FontSizeProperty, fontSizeBinding);
            tbkTitle.SetBinding(TextBlock.FontWeightProperty, fontWeightBinding);
            tbkTitle.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
            tbkTitle.SetValue(Grid.ColumnProperty, 1);
            grid.Children.Add(tbkTitle);

            TextBlock tbkContent = new TextBlock();
            tbkContent.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            tbkContent.Margin = new Thickness(4);
            Binding contentBinding = new Binding("Content");
            contentBinding.Source = this;
            tbkContent.SetBinding(TextBlock.TextProperty, contentBinding);
            tbkContent.SetBinding(TextBlock.FontSizeProperty, fontSizeBinding);
            tbkContent.SetBinding(TextBlock.FontWeightProperty, fontWeightBinding);
            tbkContent.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
            tbkContent.SetValue(Grid.ColumnProperty, 2);
            grid.Children.Add(tbkContent);

            popup.Child = grid;
        }
开发者ID:kjiwu,项目名称:WP_CustomControls,代码行数:79,代码来源:MyToast.cs

示例15: initialChildren

        // Calculated content height
        protected virtual void initialChildren()
        {
            double w = System.Windows.Application.Current.Host.Content.ActualWidth;

            topShadow = GetTemplateChild("TopShadow") as Rectangle;
            bottomShadow = GetTemplateChild("BottomShadow") as Rectangle;
            contentView = GetTemplateChild("ContentView") as Grid;
            buttonContainer = GetTemplateChild("ButtonContainer") as StackPanel;
            curtain = GetTemplateChild("Curtain") as Rectangle;

            // Add an optional title label
            titleLabel = null;
            if (title != null)
            {
                titleLabel = new TextBlock();
                titleLabel.Text = title;
                titleLabel.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xd9, 0xf3));
                titleLabel.FontSize = 42;
                titleLabel.HorizontalAlignment = HorizontalAlignment.Center;
                titleLabel.TextWrapping = TextWrapping.Wrap;
                titleLabel.TextAlignment = TextAlignment.Center;
                titleLabel.Margin = new Thickness(0, 8, 0, 8);
                titleLabel.SetValue(Grid.RowProperty, 0);
                contentView.Children.Add(titleLabel);
            }

            // Add any custom content
            if (contentElement != null)
            {
                contentElement.SetValue(Grid.RowProperty, 1);
                contentView.Children.Add(contentElement);
                contentView.InvalidateArrange();
                contentView.UpdateLayout();

                double measuredWidth = contentElement.ActualWidth + contentElement.Margin.Left + contentElement.Margin.Right;
                double measuredHeight = 0;
                if (titleLabel != null)
                {
                    measuredHeight += titleLabel.ActualHeight;
                }

                double contentHeight = Math.Max(contentElement.ActualHeight, contentElement.Height);
                if(!double.IsNaN(contentHeight))
                    measuredHeight += contentHeight + contentElement.Margin.Top + contentElement.Margin.Bottom;
                else
                    measuredHeight += 240 + contentElement.Margin.Top + contentElement.Margin.Bottom;

                expectedContentSize = new Size(measuredWidth, measuredHeight);
            }
            else
            {
                expectedContentSize = new Size(w, 240);
            }

            // Add custom buttons
            if (buttonTitles.Count > 0)
            {
                foreach (string buttonTitle in buttonTitles)
                {
                    var button = new Avarice.Controls.Button();
                    button.Content = buttonTitle;
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }
            }
            else if(Buttons.Count > 0)
            {
                foreach (var button in Buttons)
                {
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }

            }
        }
开发者ID:powerytg,项目名称:indulged-flickr,代码行数:80,代码来源:ModalPopup.cs


注:本文中的TextBlock.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。