Skip to content

Commit

Permalink
TreeView Images and DataBinding (#80)
Browse files Browse the repository at this point in the history
* Added support for SiteMap Xml documents

* Added TreeView DataBinding events

* Updated Blazor WebAssembly to 3.2 Preview 1

* Added Image and ImageToolTip support to the TreeView

* Implemented TreeViewImageSet
  • Loading branch information
csharpfritz authored Feb 12, 2020
1 parent aa5b835 commit 3090384
Show file tree
Hide file tree
Showing 98 changed files with 1,022 additions and 118 deletions.
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<BlazorWebAssemblyVersion>3.2.0-preview1.20073.1</BlazorWebAssemblyVersion>
</PropertyGroup>

</Project>
2 changes: 2 additions & 0 deletions docs/TreeView.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The TreeView component is meant to emulate the asp:TreeView control in markup an
- TreeNode expand and collapse events
- TreeNode checkbox checked / unchecked events
- XmlDocument databinding
- SiteMap databinding as an XmlDocument
- Databinding events

##### [Back to top](#treeview)

Expand Down
8 changes: 4 additions & 4 deletions samples/AfterBlazorClientSide/AfterBlazorClientSide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview4.19579.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview4.19579.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.1.0-preview4.19579.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="$(BlazorWebAssemblyVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(BlazorWebAssemblyVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="$(BlazorWebAssemblyVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="$(BlazorWebAssemblyVersion)" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 20 additions & 5 deletions samples/AfterBlazorClientSide/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
using Microsoft.AspNetCore.Blazor.Hosting;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;

namespace AfterBlazorClientSide
{
public class Program
{
public static void Main(string[] args)
public static async Task Main(string[] args)
{
CreateHostBuilder(args).Build().Run();

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");

builder.Services.AddScoped<AuthenticationStateProvider, StaticAuthStateProvider>();

await builder.Build().RunAsync();

}

public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
BlazorWebAssemblyHost.CreateDefaultBuilder()
.UseBlazorStartup<Startup>();
}

public static class Startup
{

public static string ApplicationName => "Blazor WebAssembly";

}

}
22 changes: 0 additions & 22 deletions samples/AfterBlazorClientSide/Startup.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@page "/ControlSamples/TreeView/ArrowsImages"
@using static BlazorWebFormsComponents.Enums.TreeNodeTypes
@using static BlazorWebFormsComponents.Enums.TreeViewImageSet

<h2>TreeView Component homepage</h2>

<p>Here is a simple static tree view</p>

<TreeView ID="SampleTreeView" runat="server"
OnTreeNodeCheckChanged="CheckChanged"
ImageSet="Arrows"
ShowCheckBoxes="Root|Parent">
<Nodes>
<TreeNode Value="Home"
NavigateUrl="/"
Text="Home"
Target="Content"
Expanded="true">
<TreeNode Value="Foo" Text="Foo"></TreeNode>
<TreeNode Value="Bar" Text="Bar">
<TreeNode Value="Baz" Text="Baz">
<TreeNode Value="BlazorMisterMagoo" Text="BlazorMisterMagoo">

</TreeNode>
</TreeNode>
</TreeNode>
</TreeNode>
</Nodes>
</TreeView>

Checkboxes clicked: @clickCount

@code {

public int clickCount { get; set; } = 0;

private void CheckChanged(TreeNodeEventArgs args) {

clickCount++;
base.StateHasChanged();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@page "/ControlSamples/TreeView/BulletImages"
@using static BlazorWebFormsComponents.Enums.TreeNodeTypes
@using static BlazorWebFormsComponents.Enums.TreeViewImageSet

<h2>TreeView Component homepage</h2>

<p>Here is a simple static tree view</p>

<TreeView ID="SampleTreeView" runat="server"
OnTreeNodeCheckChanged="CheckChanged"
ImageSet="BulletedList"
ShowCheckBoxes="Root|Parent">
<Nodes>
<TreeNode Value="Home"
NavigateUrl="/"
Text="Home"
Target="Content"
Expanded="true">
<TreeNode Value="Foo" Text="Foo"></TreeNode>
<TreeNode Value="Bar" Text="Bar">
<TreeNode Value="Baz" Text="Baz">
<TreeNode Value="BlazorMisterMagoo" Text="BlazorMisterMagoo">

</TreeNode>
</TreeNode>
</TreeNode>
</TreeNode>
</Nodes>
</TreeView>

Checkboxes clicked: @clickCount

@code {

public int clickCount { get; set; } = 0;

private void CheckChanged(TreeNodeEventArgs args) {

clickCount++;
base.StateHasChanged();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@page "/ControlSamples/TreeView/BulletsNoExpand"
@using static BlazorWebFormsComponents.Enums.TreeNodeTypes
@using static BlazorWebFormsComponents.Enums.TreeViewImageSet

<h2>TreeView Bullets with No Expansion</h2>

<p>Here is a simple static tree view with bullets for nodes and no expand / collapse capabilities</p>

<TreeView ID="SampleTreeView" runat="server"
ShowExpandCollapse="false"
ImageSet="BulletedList">
<Nodes>
<TreeNode Value="Home"
NavigateUrl="/"
Text="Home"
Target="Content"
Expanded="true">
<TreeNode Value="Foo" Text="Foo"></TreeNode>
<TreeNode Value="Bar" Text="Bar">
<TreeNode Value="Baz" Text="Baz">
<TreeNode Value="BlazorMisterMagoo" Text="BlazorMisterMagoo">

</TreeNode>
</TreeNode>
</TreeNode>
</TreeNode>
</Nodes>
</TreeView>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@page "/ControlSamples/TreeView/Images"
@using static BlazorWebFormsComponents.Enums.TreeNodeTypes

<h2>TreeView Component homepage</h2>

<p>Here is a simple static tree view</p>

<TreeView ID="SampleTreeView" runat="server"
OnTreeNodeCheckChanged="CheckChanged"
ShowCheckBoxes="Root|Parent">
<Nodes>
<TreeNode Value="Home"
NavigateUrl="/"
Text="Home"
Target="Content"
Expanded="true">
<TreeNode Value="Foo" Text="Foo" ImageToolTip="C# is Super!" ImageUrl="/img/csharp_56.png"></TreeNode>
<TreeNode Value="Bar" Text="Bar">
<TreeNode Value="Baz" Text="Baz">
<TreeNode Value="BlazorMisterMagoo" Text="BlazorMisterMagoo">

</TreeNode>
</TreeNode>
</TreeNode>
</TreeNode>
</Nodes>
</TreeView>

Checkboxes clicked: @clickCount

@code {

public int clickCount { get; set; } = 0;

private void CheckChanged(TreeNodeEventArgs args) {

clickCount++;
base.StateHasChanged();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Checkboxes clicked: @clickCount

public int clickCount { get; set; } = 0;

private void CheckChanged(object sender, TreeNodeEventArgs args) {
private void CheckChanged(TreeNodeEventArgs args) {

clickCount++;
base.StateHasChanged();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@page "/ControlSamples/TreeView/SiteMapDataSource"
@using static BlazorWebFormsComponents.Enums.TreeNodeTypes

<h2>TreeView SiteMapDataSource Sample</h2>

<p>This is a treeview component bound to a SiteMap xml document</p>

<TreeView @ref="SiteTreeView"
DataSource="SiteMapSource"
AutoGenerateDataBindings="False"
runat="server">

<DataBindings>

<TreeNodeBinding TextField="title" NavigateUrlField="url"/>

</DataBindings>

</TreeView>

@code {

public TreeView SiteTreeView;

System.Xml.XmlDocument SiteMapSource = new System.Xml.XmlDocument();

protected override Task OnInitializedAsync() {

Setup();

return base.OnInitializedAsync();

}

void Setup()
{

SiteMapSource.LoadXml(@"<siteMap>
<siteMapNode title=""Home"" description=""Home"" url=""default.aspx"">
<siteMapNode title=""Products"" description=""Products"" url=""Products.aspx"">
<siteMapNode title=""Computers"" url=""Computers.aspx""/>
<siteMapNode title=""Accessories"" url=""Accessories.aspx""/>
</siteMapNode>
</siteMapNode>
</siteMap>");

}

}
22 changes: 14 additions & 8 deletions samples/AfterBlazorServerSide/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using BlazorWebFormsComponents
@using static BlazorWebFormsComponents.Enums.TreeViewImageSet

<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">BlazorWebFormsComponents<br/>@Startup.ApplicationName</a>
Expand All @@ -8,14 +9,14 @@
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<TreeView CssClass="nav-item">
<TreeView CssClass="nav-item" ImageSet="_Default">
<Nodes>

<TreeNode Text="Home" NavigateUrl="/">

<TreeNode Text="Data Components">

<TreeNode Text="DataList" NavigateUrl="/ControlSamples/DataList">
<TreeNode Text="DataList" NavigateUrl="/ControlSamples/DataList" Expanded="false">
<TreeNode NavigateUrl="/ControlSamples/DataList" Text="Simple Table" />
<TreeNode NavigateUrl="/ControlSamples/DataList/Flow" Text="Simple Flow" />
<TreeNode NavigateUrl="/ControlSamples/DataList/HeaderStyle" Text="Header Style" />
Expand All @@ -24,13 +25,13 @@
<TreeNode NavigateUrl="/ControlSamples/DataList/RepeatColumns" Text="Repeat Columns" />
</TreeNode>

<TreeNode Text="ListView" NavigateUrl="/ControlSamples/ListView">
<TreeNode Text="ListView" NavigateUrl="/ControlSamples/ListView" Expanded="false">
<TreeNode NavigateUrl="/ControlSamples/ListView" Text="Simple List View"></TreeNode>
<TreeNode NavigateUrl="./ControlSamples/ListView/ModelBinding" Text="ModelBinding Sample"></TreeNode>
<TreeNode NavigateUrl="./ControlSamples/ListView/LayoutTest" Text="Layout Test"></TreeNode>
</TreeNode>

<TreeNode Text="Repeater" NavigateUrl="/ControlSamples/Repeater">
<TreeNode Text="Repeater" NavigateUrl="/ControlSamples/Repeater" Expanded="false">

</TreeNode>

Expand All @@ -47,9 +48,14 @@

<TreeNode Text="Navigation Components">

<TreeNode Text="TreeView" NavigateUrl="/ControlSamples/TreeView">
<TreeNode Text="Static TreeView" NavigateUrl="/ControlSamples/TreeView"></TreeNode>
<TreeNode Text="XML Data Source" NavigateUrl="/ControlSamples/TreeView/XmlDataSource"></TreeNode>
<TreeNode Text="TreeView" NavigateUrl="/ControlSamples/TreeView" Expanded="false">
<TreeNode Text="Arrows ImageSet" NavigateUrl="/ControlSamples/TreeView/ArrowsImages"></TreeNode>
<TreeNode Text="Bullets ImageSet" NavigateUrl="/ControlSamples/TreeView/BulletImages"></TreeNode>
<TreeNode Text="Bullets No Expand" NavigateUrl="/ControlSamples/TreeView/BulletsNoExpand"></TreeNode>
<TreeNode Text="Images" NavigateUrl="/ControlSamples/TreeView/Images"></TreeNode>
<TreeNode Text="Static TreeView" NavigateUrl="/ControlSamples/TreeView"></TreeNode>
<TreeNode Text="SiteMap Data Source" NavigateUrl="/ControlSamples/TreeView/SiteMapDataSource"></TreeNode>
<TreeNode Text="XML Data Source" NavigateUrl="/ControlSamples/TreeView/XmlDataSource"></TreeNode>
</TreeNode>

</TreeNode>
Expand All @@ -58,7 +64,7 @@

<TreeNode Text="LoginName" NavigateUrl="/ControlSamples/LoginName"></TreeNode>
<TreeNode Text="Login" NavigateUrl="/ControlSamples/Login"></TreeNode>
<TreeNode Text="LoginStatus">
<TreeNode Text="LoginStatus" Expanded="false">

<TreeNode Text="Authenticated" NavigateUrl="/ControlSamples/LoginStatusAuthenticated"></TreeNode>
<TreeNode Text="Not Authenticated" NavigateUrl="/ControlSamples/LoginStatusNotAuthenticated"></TreeNode>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions samples/BeforeWebForms/BeforeWebForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Content Include="Content\bootstrap-theme.min.css" />
<Content Include="Content\bootstrap.css" />
<Content Include="Content\bootstrap.min.css" />
<Content Include="Content\Images\csharp_56.png" />
<Content Include="Content\Site.css" />
<Content Include="ControlSamples\DataList\RepeatColumns.aspx" />
<Content Include="ControlSamples\DataList\StyleAttributes.aspx" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3090384

Please sign in to comment.