File tree Expand file tree Collapse file tree 11 files changed +53
-17
lines changed
sessions/Season-03/0303-ComponentInteractions/src/Demo Expand file tree Collapse file tree 11 files changed +53
-17
lines changed Original file line number Diff line number Diff line change 1
- <div class =" card-body" style =" color : @ BodyFontColor" >@ChildContent </div >
1
+ <div class =" card-body" style =" @($ " color: { BodyFontColor}; background-color: {BodyBgColor} " ) " >@ChildContent </div >
2
2
3
3
@code {
4
4
[Parameter ] public RenderFragment ChildContent { get ; set ; }
5
5
6
- [CascadingParameter (Name = " bodyfontcolor" )] public string BodyFontColor { get ; set ;} = " inherit" ;
6
+ [CascadingParameter (Name = " bodyfontcolor" )] public string BodyFontColor { get ; set ; }
7
+ [CascadingParameter (Name = " bodybgcolor" )] public string BodyBgColor { get ; set ; }
8
+
9
+ protected override void OnInitialized () {
10
+
11
+ Console .WriteLine ($" BodyFontColor: {BodyFontColor }" );
12
+ base .OnInitialized ();
13
+
14
+ }
15
+
7
16
8
17
}
Original file line number Diff line number Diff line change 1
- <div >Here is a button: <button @onclick =" OnClick " >The Button</button ></div >
1
+ <div >Here is a button: <button @onclick =" DoMoreWithClick " >The Button</button ></div >
2
2
3
3
@code {
4
4
Original file line number Diff line number Diff line change
1
+ <p class =" text-start" >
2
+ @ChildContent
3
+ </p >
4
+
5
+ @code {
6
+
7
+ [Parameter ] public RenderFragment ChildContent { get ; set ; }
8
+
9
+ }
Original file line number Diff line number Diff line change 2
2
3
3
<CardHeader >@HeaderText </CardHeader >
4
4
5
+ <CascadingValue Name =" BodyBgColor" Value =" @(" lightGreen " )" >
5
6
<CardBody >@ChildContent </CardBody >
7
+ </CascadingValue >
6
8
7
9
</div >
8
10
Original file line number Diff line number Diff line change 1
- <div class =" card" @attributes =" @Values" >
1
+ @using System .Collections .Generic
2
+
3
+ <div class =" card" @attributes =" Values" >
4
+ @* <div class="card" style="@(Values != null && Values.ContainsKey("style") ? Values["style"] : "")"> *@
2
5
3
6
<CardHeader >@HeaderText </CardHeader >
4
7
Original file line number Diff line number Diff line change 23
23
24
24
public int Counter = 0 ;
25
25
public string Text = string .Empty ;
26
- void ButtonClicked () {
26
+ void ButtonClicked (MouseEventArgs args ) {
27
27
Counter ++ ;
28
+ Console .WriteLine ($" Shift button pressed: {args .ShiftKey }" );
28
29
}
29
30
30
31
void TextChanged (ChangeEventArgs args ) {
Original file line number Diff line number Diff line change 2
2
3
3
<h1 >Other Attributes and Parameters</h1 >
4
4
5
- <TheCard HeaderText =" Blazor Hat" style =" text-decoration : underline ;" >
5
+ <pre >
6
+ < ; TheCard HeaderText="Blazor Hat" style="text-decoration: underline;"> ;
6
7
Another of Fritz's hats
7
- </TheCard >
8
+ < ; /TheCard> ;
9
+ </pre >
10
+
11
+ <TheCardStyle HeaderText =" Blazor Hat" >
12
+ Another of Fritz's hats
13
+ </TheCardStyle >
Original file line number Diff line number Diff line change 6
6
</p >
7
7
8
8
<pre >
9
- < ; TheCard HeaderText="Blazor Hat"> ;
10
- < ; b> ; Acquired:< ; /b> ; May 2020
11
- < ; /TheCard> ;
9
+ < ; CascadingValue Name="BodyFontColor" Value="@( " red" ) "> ;
10
+ < ; TheCard HeaderText="Blazor Hat"> ;
11
+ < ; b> ; Acquired:< ; /b> ; May 2020
12
+ < ; /TheCard> ;
13
+ < ; /CascadingValue> ;
12
14
</pre >
13
15
14
- <CascadingValue Name =" BodyFontColor" Value =" @(" red " )" >
15
- <TheCard HeaderText =" Blazor Hat" >
16
- <b >Acquired:</b > May 2020
17
- </TheCard >
16
+ <CascadingValue Name =" BodyBgColor" Value =" @(" lightBlue " )" >
17
+ <CascadingValue Name =" BodyFontColor" Value =" @(" purple " )" >
18
+ <TheCard HeaderText =" Blazor Hat" >
19
+ <b >Acquired:</b > May 2020
20
+ </TheCard >
21
+ </CascadingValue >
18
22
</CascadingValue >
Original file line number Diff line number Diff line change 1
1
@page " /5_State"
2
- @* @ inject State currentValue *@
2
+ @inject State currentValue
3
3
4
4
<h1 >Managing State Between Pages</h1 >
5
5
@@ -9,7 +9,7 @@ This is a counter: <span>@currentValue.CurrentCount</span>
9
9
10
10
@code {
11
11
12
- State currentValue = new State ();
12
+ @* State currentValue = new State(); *@
13
13
14
14
void Increment () {
15
15
Original file line number Diff line number Diff line change 9
9
<li ><a href =" /4_Cascading" >Cascading Parameters</a ></li >
10
10
<li ><a href =" /5_State" >Session State</a ></li >
11
11
</ol >
12
+
13
+ <Textbox >This is my textbox for r_shiyaa</Textbox >
You can’t perform that action at this time.
0 commit comments