Windows App can't use Grid MemberFunction - c#

Ihave some Problems to attach Textblocks in my Grid.
I cant use SetRow(Frameworkelement,index);
The ErrorMessage is something like that I cant access the MemberFunction with an instance reference.
Instead i should use a TypeName, but how?
private FrameworkElement CreateGrid(int i)
{
double w = 775;
double l = 1105;
TextBlock header = CreateHeader("someRndStuffHeader");
RowDefinition headerRowDefinition = new RowDefinition
{
MinHeight = header.ActualHeight,
MaxHeight = header.ActualHeight,
};
TextBlock footer = CreateFooter("someRndStuffFooter");
RowDefinition footerRowDefinition = new RowDefinition
{
MinHeight = footer.ActualHeight,
MaxHeight = footer.ActualHeight
};
double contentHeight = l- header.ActualHeight - footer.ActualHeight;
RowDefinition contentRowDefinition = new RowDefinition
{
MinHeight = contentHeight,
MaxHeight = contentHeight,
};
ColumnDefinition gridColumnDefinition = new ColumnDefinition()
{
MaxWidth = w,
MinWidth = w,
};
Grid page = new Grid();
string name = "printPage" + i.ToString();
page.Name = name;
page.RowDefinitions.Add(headerRowDefinition);
page.RowDefinitions.Add(contentRowDefinition);
page.RowDefinitions.Add(footerRowDefinition);
page.ColumnDefinitions.Add(gridColumnDefinition);
// I CANT USE THIS
page.SetRow(header, 1);
return page;
}

SetRow(FrameworkElement framework,int value) is a static method. Instance members cannot use it.
Use like this :-
Grid.SetRow(header,1);
However, before you can achieve that, you have to make header and footer TextBlocks children of the newly formed grid because SetRow method sets the row of framework element only when it is a child of any grid.
So you will have to add these two statements :-
page.Children.Add(header);
page.Children.Add(footer);
Further, here the new grid i.e page, it has to be also assigned a parent grid. When you create a new AppPage (BlankPage.xaml) then by default a parent grid is already rendered by the system. Name this parent grid as say x:Name="Layout" and then add grid 'page' to this 'Layout' grid. I am giving here full code, both xaml and .cs. I have created a button and then when i press the button, new grid is created
In XAMl :-
<Grid x:Name="layout" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Button" HorizontalAlignment="Left" Margin="587,475,0,0" VerticalAlignment="Top" Click="Button_Click"/>
</Grid>
In .cs :-
private FrameworkElement CreateGrid(int i)
{
double w = 775;
double l = 1105;
TextBlock header = CreateHeader("someRndStuffHeader");
RowDefinition headerRowDefinition = new RowDefinition
{
MinHeight = header.ActualHeight,
MaxHeight = header.ActualHeight,
};
TextBlock footer = CreateFooter("someRndStuffFooter");
RowDefinition footerRowDefinition = new RowDefinition
{
MinHeight = footer.ActualHeight,
MaxHeight = footer.ActualHeight
};
double contentHeight = l - header.ActualHeight - footer.ActualHeight;
RowDefinition contentRowDefinition = new RowDefinition
{
MinHeight = contentHeight,
MaxHeight = contentHeight,
};
ColumnDefinition gridColumnDefinition = new ColumnDefinition()
{
MaxWidth = w,
MinWidth = w,
};
Grid page = new Grid();
string name = "printPage" + i.ToString();
page.Name = name;
page.RowDefinitions.Add(headerRowDefinition);
page.RowDefinitions.Add(contentRowDefinition);
page.RowDefinitions.Add(footerRowDefinition);
page.ColumnDefinitions.Add(gridColumnDefinition);
**Grid.SetRow(header, 1);
page.Children.Add(header);
page.Children.Add(footer);**
return page;
}
private TextBlock CreateFooter(string p)
{
return new TextBlock() { Width=300,Height=300,Text=p};
}
private TextBlock CreateHeader(string p)
{
return new TextBlock() { Width = 300, Height = 300, Text = p };
}
private void Button_Click(object sender, RoutedEventArgs e)
{
layout.Children.Add(CreateGrid(1));
}

Related

TextBlock doesn't want to adjust grid columns

I'm preparing control to present some data. It is built in the following way:
-> ScrollViewer
--> StackPanel
---> Border
----> Grid
---> Border
----> Grid
...
---> Border
----> Grid
And there is my code for each item
public class PresenterItem : Border
{
// Variables
private Submission submission;
private int index;
private Grid grid = new Grid();
// Constructor
public PresenterItem(int i, Submission subm)
{
index = i;
submission = subm;
Child = grid;
Background = Global.GET_BRUSH("ItemBackground");
CornerRadius = new CornerRadius(5);
Margin = new Thickness(0, 0, 0, 10);
Padding = new Thickness(5);
grid.ShowGridLines = true;
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(40, GridUnitType.Pixel) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40, GridUnitType.Pixel) });
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30, GridUnitType.Pixel) });
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
InsertContent();
}
private Label CreateLabel(int row, int column, string content, int columnSpan = 1)
{
Label newLabel = new Label();
newLabel.Content = content;
Grid.SetRow(newLabel, row);
Grid.SetColumn(newLabel, column);
Grid.SetColumnSpan(newLabel, columnSpan);
grid.Children.Add(newLabel);
return newLabel;
}
private TextBlock CreateTextBlock(int row, int column, int columnSpan = 1)
{
TextBlock newTextBlock = new TextBlock();
newTextBlock.Foreground = Brushes.Silver;
Grid.SetRow(newTextBlock, row);
Grid.SetColumn(newTextBlock, column);
Grid.SetColumnSpan(newTextBlock, columnSpan);
grid.Children.Add(newTextBlock);
return newTextBlock;
}
private void InsertContent()
{
// Number
Label number = CreateLabel(0, 0, $"#{index + 1}");
number.HorizontalAlignment = HorizontalAlignment.Center;
number.VerticalAlignment = VerticalAlignment.Center;
number.FontSize = 17;
// Header
Label header = CreateLabel(0, 1, $"{submission.Name} ({submission.Rank})");
header.Foreground = Global.GET_BRUSH("HeaderForeground");
header.HorizontalAlignment = HorizontalAlignment.Left;
header.VerticalAlignment = VerticalAlignment.Center;
header.FontSize = 17;
// Timestamp
TextBlock timestamp = CreateTextBlock(0, 2);
timestamp.Inlines.Add(new Run("Timestamp"));
timestamp.Inlines.Add(new Run($"{submission.Timestamp}") { Foreground = Global.GET_BRUSH("HeaderForeground") });
timestamp.HorizontalAlignment = HorizontalAlignment.Right;
timestamp.VerticalAlignment = VerticalAlignment.Center;
timestamp.FontSize = 13.5;
// Range
TextBlock range = CreateTextBlock(1, 1);
range.Inlines.Add(new Run("Some text "));
range.Inlines.Add(new Run($"{submission.Range.ToStringWithDayNames()}") { Foreground = Global.GET_BRUSH("HeaderForeground") });
range.HorizontalAlignment = HorizontalAlignment.Left;
range.VerticalAlignment = VerticalAlignment.Center;
range.Margin = new Thickness(5, 0, 0, 0);
range.FontSize = 13.5;
// Conflict
Label conflict = CreateLabel(1, 2, "Nie wykryto konfliktu");
conflict.Foreground = Global.GET_BRUSH("GreenForeground");
conflict.HorizontalAlignment = HorizontalAlignment.Right;
conflict.VerticalAlignment = VerticalAlignment.Center;
conflict.FontSize = 13.5;
// Content
TextBlock content = CreateTextBlock(2, 1, 2);
content.Inlines.Add(new Run($"{submission.Content}"));
cotent.HorizontalAlignment = HorizontalAlignment.Left;
content.VerticalAlignment = VerticalAlignment.Top;
content.Margin = new Thickness(5, 0, 0, 0);
content.TextWrapping = TextWrapping.WrapWithOverflow;
content.FontSize = 13.5;
}
How it looks like
It perfectly works but when I added last TextBlock whole control is stretching to the right. In designer the same way of creating elements works, but in code no. What am I doing wrong?
I would like to achieve this effect with column 1 and 2 with the same width everywhere.
What I want
You have to set the dependency property Grid.IsSharedSizeScope to true in the StackPanel and then set the Property SharedSizeGroup for every ColumnDefinition to a string that definies the group with same size.
I dealt with this problem on my own. If someone will be having the same problem like me, I will write how to repair it.
In the place where my app initializes ScrollViewer I set property HorizontalScrollBarVisibility to Hidden. After setting this property to Disabled everything starts to work correctly.
There is something about this:
https://crmdev.wordpress.com/2010/01/16/how-to-deal-with-stubborn-silverlight-a-k-a-stubborn-me/

How to dynamically create and modify a new Grid row elements?

I'm just starting a new WPF app.
I have a grid and want to create the rows dynamically (pressing a button for example) and then create TextView/ProgressBar inside this row.
I already searched how to create the gridrows programatically. But in every solution, i can't access what's inside and it becomes useless.
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="AddLineButton" Content="Click to add a new line" Click="AddLineButton_Click"/>
<Grid x:Name="beGrid" Grid.Row="1">
<!-- I need my new rows here -->
</Grid>
</Grid>
int i = 0; //nb of rows
private void AddLineButton_Click(object sender, RoutedEventArgs e)
{
Create_line();
i++;
}
private void Create_line()
{
RowDefinition gridRow = new RowDefinition();
gridRow.Height = new GridLength(1, GridUnitType.Star);
beGrid.RowDefinitions.Add(gridRow);
StackPanel stack = new StackPanel();
stack.Orientation = Orientation.Horizontal;
TextBlock textBlock = new TextBlock();
textBlock.Text = "Question";
textBlock.Name = "Test" + i.ToString();
stack.Children.Add(textBlock);
beGrid.Children.Add(stack);
Grid.SetRow(stack, i);
}
I can't access a previously created element.
AFTER ANSWER :
private void Create_line()
{
RowDefinition gridRow = new RowDefinition();
gridRow.Height = new GridLength(1, GridUnitType.Star);
beGrid.RowDefinitions.Add(gridRow);
StackPanel stack = new StackPanel();
stack.Orientation = Orientation.Horizontal;
TextBlock textBlock = new TextBlock();
textBlock.Text = "Question";
textBlock.Name = "Test" + i.ToString();
RegisterName(textBlock.Name, textBlock);
stack.Children.Add(textBlock);
beGrid.Children.Add(stack);
Grid.SetRow(stack, i);
}
To get the created TextBlock : var text = (TextBlock)FindName("Test"+i.ToString());
you can store all created StackPanel in a List.
private void AddLineButton_Click(object sender, RoutedEventArgs e)
{
Create_line();
}
List<StackPanel> items;
private void Create_line()
{
RowDefinition gridRow = new RowDefinition();
gridRow.Height = new GridLength(1, GridUnitType.Star);
beGrid.RowDefinitions.Add(gridRow);
StackPanel stack = new StackPanel();
stack.Orientation = Orientation.Horizontal;
int i = items.Count + 1;
TextBlock textBlock = new TextBlock();
textBlock.Text = "Question";
textBlock.Name = "Test" + i.ToString();
stack.Children.Add(textBlock);
beGrid.Children.Add(stack);
Grid.SetRow(stack, items.Count);
items.Add(stack);
}
you can access any previos panel by index, e.g. items[0], and get elements from Children property: items[0].Children[0] as TextBlock
Creating controls manually like this is really not the WPF way ...
The best methodology is to define an item class that holds properties for each value that you want to display / edit.
Then create an ObservableCollection (since you will be manually adding items on a button click) of these items within your Window, and set this as the ItemsSource property of an ItemsControl control. A DataTemplate is used to define the exact controls to display each item within the control, which will bind to the properties of the item.

Pass Parameters to Tap Gesture Xamarin Forms

I am trying to pass parameters from a page to another page. These passed parameters will be used to select from an SQL table.
The page is built as follows: (The code behind)
private MainRoutePageViewModel mainroutepageviewmodel;
private List<RouteInfo> routeinfo;
Constructor:
public MainRoutePageViewDetail(MessagDatabase database)
{
InitializeComponent();
BindingContext = mainroutepageviewmodel = new MainRoutePageViewModel(database,Navigation);
//_listOfProperties = mainroutepageviewmodel.GetLabelInfo();
ScrollView scrollview = new ScrollView();
StackLayout mainstack = new StackLayout();
mainstack.Spacing = 0;
mainstack.Padding = 0;
//mainstack.HeightRequest = 2000;
routeinfo = mainroutepageviewmodel.GetLabelInfo();
string _routePlacer = "";
foreach (var i in routeinfo)
{
mainstack.Children.Add(NewRouteName(i.RouteName));
mainstack.Children.Add(BuildNewRoute(i.RouteStops,i));
_routePlacer = i.RouteName;
}
scrollview.Content = mainstack;
Content = scrollview;
}// end of constructor
The BuildNewRoute method:
public StackLayout BuildNewRoute(List<string> location, RouteInfo routeinfo)
{
StackLayout stackLayout = new StackLayout();
//stackLayout.HeightRequest = 1000;
foreach (var i in location) {
StackLayout stackLayout2 = new StackLayout();
stackLayout2.HeightRequest = 200;
Grid grid = new Grid();
grid.ColumnSpacing = 0;
grid.RowSpacing = 0;
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(15, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(55, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(18, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(18, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(18, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(10, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(15, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) });
TapGestureRecognizer ArrowtapGesture = new TapGestureRecognizer();
ArrowtapGesture.Tapped += ArrowtapGesture_Tapped;
// Arrow icon
Image arrowimage = new Image();
arrowimage.Source = "Resources/arrow.png";
arrowimage.VerticalOptions = LayoutOptions.Center;
arrowimage.HorizontalOptions = LayoutOptions.Center;
arrowimage.GestureRecognizers.Add(ArrowtapGesture);
grid.Children.Add(arrowimage,7,6);
// total weight labels
Label weightlabel = new Label();
weightlabel.Text = "Total Weight [kg]: ";
grid.Children.Add(weightlabel,1,5,3,4);
// total items labels
Label itemsLabel = new Label();
itemsLabel.Text = "Total Items: ";
grid.Children.Add(itemsLabel, 1, 5, 4, 5);
// underline labels
Label firstunderline = new Label();
Label secondunderline = new Label();
firstunderline.BackgroundColor = Color.Black;
secondunderline.BackgroundColor = Color.Black;
grid.Children.Add(firstunderline,0,9,0,1);
grid.Children.Add(secondunderline,0,9,2,3);
// address label
Label labelLocation = new Label();
labelLocation.Text = i;
grid.Children.Add(labelLocation, 0, 3);
//sequence label
Label sequencelable = new Label();
sequencelable.Text = "Sequence: ";
sequencelable.VerticalTextAlignment = TextAlignment.Center;
grid.Children.Add(sequencelable, 0, 1);
// slot label
Label slotlabel = new Label();
slotlabel.Text = "ETA/Slot: ";
slotlabel.VerticalTextAlignment = TextAlignment.Center;
grid.Children.Add(slotlabel,1,4,1,2);
// time label
Label timelabel = new Label();
timelabel.Text = "Time: ";
timelabel.VerticalTextAlignment = TextAlignment.Center;
grid.Children.Add(timelabel, 4, 5,1,2);
// Status label
Label statuslabel = new Label();
statuslabel.Text = "Status: ";
statuslabel.VerticalTextAlignment = TextAlignment.Center;
grid.Children.Add(statuslabel, 5, 6,1,2);
//start button
Button startbutton = new Button();
startbutton.Text = "Pending";
startbutton.BackgroundColor = Color.Gray;
grid.Children.Add(startbutton,5,8,4,6);
// Phone book image
Image bookImage = new Image();
//bookImage.BackgroundColor = Color.White;
bookImage.Source = "Resources/phoneWithBook.png";
bookImage.VerticalOptions = LayoutOptions.Center;
bookImage.HorizontalOptions = LayoutOptions.Center;
grid.Children.Add(bookImage,1,2,6,7);
//Globe image
Image GlobeImage = new Image();
// GlobeImage.BackgroundColor = Color.White;
GlobeImage.Source = "Resources/globe.png";
GlobeImage.VerticalOptions = LayoutOptions.Center;
GlobeImage.HorizontalOptions = LayoutOptions.Center;
grid.Children.Add(GlobeImage, 2, 3, 6, 7);
stackLayout2.Children.Add(grid);
stackLayout.Children.Add(stackLayout2);
}
return stackLayout;
}
As you can probably see it loops through a list of collected data and adds grids and labels to a main StackLayout.
This is not the issue the page building works fine.
What you can see is the arrow icon image that has a tap gesture attached to it. This tap gesture uses the view model to open the next page.
The tap gesture:
private async void ArrowtapGesture_Tapped(object sender, EventArgs e)
{
await mainroutepageviewmodel.OpenStopDetail();
}
And the OpenStopDetail method:
public async Task OpenStopDetail()
{
await Navigation.PushAsync(new StopDetailPageView());
}
I want to know how to pass parameters from the tap event through to the StopDetailView page.
Specifically the text from the sequence label.
Some things I have tried, have been using the casting in the tap event but this seems to be bound to the item that is selected. In other words its giving me access to image properties. Which is no good for my situation.
I cant seem to find a way to access each label property individually to pass as a parameter. Sorry if this isn't clear, it was tough to explain. Let me know if more detail is needed.
You should be able to use the CommandParameter of the TapGestureRecognizer.
In XAML:-
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"
CommandParameter="Value"/>
e.Parameter will be whatever you set in the CommandParameter.
private async void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
Edit:
It has been pointed out that the above is not the right signature, the param, needs to be EventArgs and cast to TappedEventArgs.
private async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
var param = ((TappedEventArgs)e).Parameter;
}
The sender of the Tapped event will be the control the gesture recognizer is attached to - in your case, an Image. So you can add your data to one of the Image's properties in order to access it from your event handler.
// assign parameter to ClassId (must be a string)
arrowimage.ClassId = "blah";
arrowimage.GestureRecognizers.Add(ArrowtapGesture);
private async void ArrowtapGesture_Tapped(object sender, EventArgs e)
{
// retrieve parameter from sender's ClassId
var parm = ((Image)sender).ClassId;
await mainroutepageviewmodel.OpenStopDetail();
}
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Share_Tapped" CommandParameter="{Binding .}"/>
</Image.GestureRecognizers>
enter code here
private void Share_Tapped(object sender, TappedEventArgs e)
{
var contact = (e.Parameter) as DetailList;
}
Result

How to make dynamic accordion content?

I'm using this accordion control in WPF application : ayoutToolkit:Accordion.
I need to make dynamic content from database.
I tried like this:
private void RebuildView(Accordion accordion)
{
var scrollView = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Auto};
var grid = new Grid
{
ShowGridLines = true,
ColumnDefinitions =
{
new ColumnDefinition(),
new ColumnDefinition(),
}
};
int i = 0;
foreach (AttributeModel item in ViewModel.Attributes)
{
RowDefinition row = new RowDefinition { Height = new GridLength(60) };
grid.RowDefinitions.Add(row);
var label = new Label { Content = item.label, Foreground = Brushes.Black, FontSize = 20 };
Grid.SetRow(label, i);
Grid.SetColumn(label,0);
grid.Children.Add(label);
i++;
}
scrollView.Content = grid;
accordion.ContentTemplate = new DataTemplate(scrollView);
}
but I'm not sure how to make it.

How to give tap (or tapped) event to dynamically created TextBlock

public void myTextBlock1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
StackPanel mystack = new StackPanel() { Height = 100, Width = 200 };
TextBlock myTextBlock1 = new TextBlock()
{ Text = "Text Block", Width = 350, Height = 40, FontSize = 20,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center, };
mystack.Children.Add(myTextBlock1);
}
for (int r = 0; r < m; r++)
{
TextBlock myTextBlockr = new TextBlock()
{ Text = "Text Block", Width = 350, Height = 40, FontSize = 20,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center };
if (r == 0)
{
myTextBlockr.Tap += new
EventHandler<GestureEventArgs> (myTextBlock1_Tap);
}
stack1.Children.Add(myTextBlockr);
myTextBlockr.Text = a[r];
}
I want to trigger an event dynamically when a text block is created.There are no errors generated but the tap (or tapped for UWP) event doesn't trigger the function.
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
int m = 3;
InitializeComponent();
for (int r = 0; r < m; r++)
{
TextBlock myTextBlock = new TextBlock()
{
Text = "Text Block",
Width = 350,
Height = 40,
FontSize = 20,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center
};
//If tap event required for all text box
myTextBlock.Tap += myTextBlock1_Tap;
//According to your code here you have triggered tap event
//only for the first textblock
if (r == 0)
{
myTextBlock.Tap += new
EventHandler<GestureEventArgs>(myTextBlock1_Tap);
}
// Adding to the parent Stackpanel
stack1.Children.Add(myTextBlock);
myTextBlock.Text = "My textblock "+r;
}
}
public void myTextBlock1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
StackPanel mystack = new StackPanel() { Height = 100, Width = 200 };
TextBlock myTextBlock1 = new TextBlock()
{
Text = "Text Block",
Width = 350,
Height = 40,
FontSize = 20,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
};
mystack.Children.Add(myTextBlock1);
// Adding to the parent Stackpanel
stack1.Children.Add(mystack);
}
}
This code is working , have executed and checked the same

Categories