Skip to content

Commit

Permalink
docs: Change Assign usage for Name
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Mar 8, 2024
1 parent ec44fed commit 071fb9d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
7 changes: 3 additions & 4 deletions doc/Learn/Markup/Binding101.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,11 @@ public partial class MainPage : Page
this.DataContext<MyViewModel>((page, vm) => page
.Content(
new TextBox()
.Assign(out var searchBox)
.Text(() => vm.Query)
.Name("SearchBox"),
.Name(out var searchBox)
.Text(() => vm.Query),
new TextBox()
.Text(x => x
.Source("SearchBox")
.Source(searchBox)
.Binding(() => searchBox.Text))
)
);
Expand Down
2 changes: 1 addition & 1 deletion doc/Learn/Markup/DependencyPropertyBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If you wish to perform tasks such as manipulate the value of the binding or form
Sometimes you aren't binding to the `DataContext` of element and instead you need to reference another source. With WinUI we have 2 ways of doing this. The first is that we could specify a source directly such as:

```cs
new Slider().Assign(out var slider),
new Slider().Name(out var slider),
new TextBlock()
.Text(x => x
.Source(slider)
Expand Down
2 changes: 1 addition & 1 deletion doc/Learn/Markup/HowTo-CustomMarkupProject-Theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ new Grid().RowDefinitions<Grid>("*, *")
.Grid(column: 0)
.Content("Toggle Theme")
.HorizontalAlignment(HorizontalAlignment.Right)
.Assign(out var toggle)
.Name(out var toggle)
),
```

Expand Down
28 changes: 14 additions & 14 deletions doc/Learn/Markup/HowTo-CustomMarkupProject-Toolkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The navigation bar can include items such as a back button, a page title, and ot
new NavigationBar().Content("Title Second Page"),
new Button()
.Content("Go to Main Page")
.Assign(out var navigationButton)
.Name(out var navigationButton)
));

navigationButton.Click += (s, e) =>
Expand All @@ -72,10 +72,10 @@ The navigation bar can include items such as a back button, a page title, and ot
```csharp
new Button()
.Content("Go to Second Page")
.Assign(out var navigationButton),
.Name(out var navigationButton),
```

The main ideia here is to create a button that have Assign it self the output variable named in this case as navigationButton.
The main ideia here is to create a button that have assign itself, through the `Name` extension method, the output variable named in this case as `navigationButton`.
After that we need to add a Click EventHandler to add the Navigation using the Frame.Navigate.

> Notice how simple it is to create an action for the Button's Click event.
Expand Down Expand Up @@ -168,7 +168,7 @@ The navigation bar can include items such as a back button, a page title, and ot
new NavigationBar().Content("Title Main Page"),
new Button()
.Content("Go to Second Page")
.Assign(out var navigationButton)
.Name(out var navigationButton)
));

navigationButton.Click += (s, e) =>
Expand Down Expand Up @@ -242,13 +242,13 @@ Chips are often used to display short pieces of information such as tags, catego

```csharp
new ChipGroup()
.Assign(out var chipGroup)
.Name(out var chipGroup)
.Items(
new Chip()
.Margin(5)
.Content("Go to Second Page")
.Background(new SolidColorBrush(Colors.LightBlue))
.Assign(out var navigationChip),
.Name(out var navigationChip),
)
```

Expand All @@ -259,7 +259,7 @@ Chips are often used to display short pieces of information such as tags, catego

```csharp
new ChipGroup()
.Assign(out var chipGroup)
.Name(out var chipGroup)
.Items(
new Chip()
.Margin(5)
Expand All @@ -274,18 +274,18 @@ Chips are often used to display short pieces of information such as tags, catego

```csharp
new ChipGroup()
.Assign(out var chipGroup)
.Name(out var chipGroup)
.Items(

new Chip()
.Margin(5)
.Content("Chip 3")
.Assign(out var chipElement)
.Name(out var chipElement)
)
```

And we need to add the event handlers on our code.
Notice that we are using the Assign to have access to the chipElement in other places.
Notice that we are using the `Name` extension method to have access to the chipElement in other places.

```csharp

Expand Down Expand Up @@ -392,9 +392,9 @@ Chips are often used to display short pieces of information such as tags, catego
.Children(
new Button()
.Content("Go to Second Page")
.Assign(out var navigationButton),
.Name(out var navigationButton),
new ChipGroup()
.Assign(out var chipGroup)
.Name(out var chipGroup)
.Items(
new Chip()
.Margin(5)
Expand All @@ -404,7 +404,7 @@ Chips are often used to display short pieces of information such as tags, catego
.Margin(5)
.CanRemove(true)
.Content("Chip 2")
.Assign(out var chipRemoveElement)
.Name(out var chipRemoveElement)
.Style(new Style<Chip>()
.Setters(s => s.Foreground(new SolidColorBrush(Colors.Red)))
),
Expand All @@ -413,7 +413,7 @@ Chips are often used to display short pieces of information such as tags, catego
.Content("Chip 3")
//.Icon(new PathIcon().Data(StaticResource.Get<Geometry>("Icon_Check")))
//.Icon(new SymbolIcon(Symbol.Favorite))
.Assign(out var chipElement)
.Name(out var chipElement)
)
)
)
Expand Down
22 changes: 11 additions & 11 deletions doc/Learn/Markup/HowTo-CustomMarkupProject-VisualStates.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ It provides a way to create custom components that can be used in multiple parts
this.Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush"))
.Content(
new ChipGroup()
.Assign(out var chipGroup)
.Name(out var chipGroup)
.Items(
new Chip()
.Margin(5)
.Content("First Chip")
.Background(new SolidColorBrush(Colors.LightBlue))
.Assign(out var navigationChip),
.Name(out var navigationChip),
new Chip()
.Margin(5)
.Content("Chip 2")
Expand All @@ -49,7 +49,7 @@ It provides a way to create custom components that can be used in multiple parts
new Chip()
.Margin(5)
.Content("Chip 3")
.Assign(out var chipElement)
.Name(out var chipElement)
)
);
```
Expand Down Expand Up @@ -80,7 +80,7 @@ It provides a way to create custom components that can be used in multiple parts
.Children(
new Button()
.Content("Go to Second Page")
.Assign(out var navigationButton),
.Name(out var navigationButton),
new SampleUserControl()
)
```
Expand Down Expand Up @@ -109,7 +109,7 @@ It provides a way to create custom components that can be used in multiple parts
.Children(
new Button()
.Content("Go to Main Page")
.Assign(out var navigationButton),
.Name(out var navigationButton),
new SampleUserControl()
)
)
Expand Down Expand Up @@ -245,7 +245,7 @@ It provides a way to create custom components that can be used in multiple parts
.Children(
new Button()
.Content("Go to Second Page")
.Assign(out var navigationButton),
.Name(out var navigationButton),
new SampleUserControl()
)
)
Expand Down Expand Up @@ -345,7 +345,7 @@ With this we can control events and changes.
)
```

We will change the navigationButton (the same that has been Assign for control the Navigation) and will the Background Color now.
We will change the navigationButton (the same that has been assigned for controlling the navigation) and change its background color now.
And change the value of the Width of the Button that will be used on the EventHandler.
You can add the Button before the `new SampleUserControl()`.

Expand All @@ -354,7 +354,7 @@ With this we can control events and changes.
.Width(200)
.Height(40)
.Content("VisualStateManager Test")
.Assign(out var btn),
.Name(out var btn),
```

And to handle the Event Handlers we need to create the Event Handlers so that the events are fired and the actions happen.
Expand Down Expand Up @@ -408,7 +408,7 @@ With this we can control events and changes.
new Button()
.Grid(row: 1)
.Content("Visual State on UserControl")
.Assign(out var visualStateButtonChips)
.Name(out var visualStateButtonChips)
```

And to handle the Event Handlers we need to create the Event Handlers so that the events are fired and the actions happen.
Expand Down Expand Up @@ -581,12 +581,12 @@ With this we can control events and changes.
.Children(
new Button()
.Content("Go to Second Page")
.Assign(out var navigationButton),
.Name(out var navigationButton),
new Button()
.Width(200)
.Height(40)
.Content("VisualStateManager Test")
.Assign(out var btn),
.Name(out var btn),
new SampleUserControl()
)
)
Expand Down

0 comments on commit 071fb9d

Please sign in to comment.