forked from morganstanley/ComposeUI
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/morganstanley/ComposeUI/issues/47
added a simple reference application showing communications between different visual plugins via a shared view model.
- Loading branch information
Showing
18 changed files
with
963 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...round/Plugins/ViewViewModelPlugins/SingleStudentDetailView/SingleStudentDetailView.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> | ||
<Exec Command="xcopy "$(OutDir)\$(AssemblyName).dll" "$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\ViewPlugins\$(ProjectName)\" /R /Y /I" /> | ||
<Exec Command="xcopy "$(OutDir)\$(AssemblyName).pdb" "$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\ViewPlugins\$(ProjectName)\" /R /Y /I" /> | ||
</Target> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.VisualUtils\MorganStanley.ComposeUI.Playground.VisualUtils.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
29 changes: 29 additions & 0 deletions
29
...ound/Plugins/ViewViewModelPlugins/SingleStudentDetailView/Views/StudentDetailedView.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:np="https://np.com/visuals"> | ||
<DataTemplate x:Key="StudentDetailView"> | ||
<np:AutoGrid DataContext="{Binding Path=TheSelectedItem}"> | ||
<np:AutoGrid.Styles> | ||
<Style Selector="np|LabeledControl"> | ||
<Setter Property="ContainedControlTemplate"> | ||
<Setter.Value> | ||
<ControlTemplate> | ||
<TextBlock Text="{Binding}"/> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="Margin" | ||
Value="0,0,0,10"/> | ||
</Style> | ||
</np:AutoGrid.Styles> | ||
<np:LabeledControl Text="First Name:" | ||
DataContext="{Binding Path=FirstName}"/> | ||
<np:LabeledControl Text="Last Name:" | ||
DataContext="{Binding Path=LastName}" | ||
np:AutoGrid.Row="1"/> | ||
<np:LabeledControl Text="Major:" | ||
DataContext="{Binding Path=Major}" | ||
np:AutoGrid.Row="2"/> | ||
</np:AutoGrid> | ||
</DataTemplate> | ||
</ResourceDictionary> |
18 changes: 18 additions & 0 deletions
18
Playground/Plugins/ViewViewModelPlugins/StudentsGridView/StudentsGridView.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> | ||
<Exec Command="xcopy "$(OutDir)\$(AssemblyName).dll" "$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\ViewPlugins\$(ProjectName)\" /R /Y /I" /> | ||
<Exec Command="xcopy "$(OutDir)\$(AssemblyName).pdb" "$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\ViewPlugins\$(ProjectName)\" /R /Y /I" /> | ||
</Target> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.VisualUtils\MorganStanley.ComposeUI.Playground.VisualUtils.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
Playground/Plugins/ViewViewModelPlugins/StudentsGridView/Views/StudentsDictionary.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<DataTemplate x:Key="StudentsDataGrid"> | ||
<DataGrid AutoGenerateColumns="False" | ||
Items="{Binding}" | ||
SelectedItem="{Binding TheSelectedItem, Mode=TwoWay}"> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="First Name" | ||
Binding="{Binding Path=FirstName}"/> | ||
<DataGridTextColumn Header="Last Name" | ||
Binding="{Binding Path=LastName}"/> | ||
<DataGridTextColumn Header="Major" | ||
Binding="{Binding Path=Major}"/> | ||
</DataGrid.Columns> | ||
|
||
</DataGrid> | ||
</DataTemplate> | ||
</ResourceDictionary> |
21 changes: 21 additions & 0 deletions
21
Playground/Plugins/ViewViewModelPlugins/StudentsViewModel/Student.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using NP.Concepts.Behaviors; | ||
using System; | ||
|
||
namespace MorganStanley.GridSelectionPrototype | ||
{ | ||
public class Student : SelectableItem<Student> | ||
{ | ||
public int StudentID { get; set; } | ||
|
||
public string? FirstName { get; set; } | ||
|
||
public string? LastName { get; set; } | ||
|
||
public string? Major { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return $"{FirstName} {LastName}"; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Playground/Plugins/ViewViewModelPlugins/StudentsViewModel/StudentsViewModel.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> | ||
<Exec Command="xcopy "$(OutDir)\$(AssemblyName).dll" "$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\ViewModelPlugins\$(ProjectName)\" /R /Y /I" /> | ||
<Exec Command="xcopy "$(OutDir)\$(AssemblyName).pdb" "$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\ViewModelPlugins\$(ProjectName)\" /R /Y /I" /> | ||
</Target> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.BasicModels\MorganStanley.ComposeUI.Playground.BasicModels.csproj" /> | ||
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.Interfaces\MorganStanley.ComposeUI.Playground.Interfaces.csproj" /> | ||
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.Utilities\MorganStanley.ComposeUI.Playground.Utilities.csproj" /> | ||
</ItemGroup> | ||
</Project> |
33 changes: 33 additions & 0 deletions
33
Playground/Plugins/ViewViewModelPlugins/StudentsViewModel/TestStudents.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using NP.Concepts.Behaviors; | ||
using NP.Utilities.Attributes; | ||
using NP.Utilities.PluginUtils; | ||
|
||
namespace MorganStanley.GridSelectionPrototype | ||
{ | ||
[Implements(typeof(IPlugin), partKey:"StudentsViewModel", IsSingleton = true)] | ||
public class TestStudents : SingleSelectionObservableCollection<Student>, IPlugin | ||
{ | ||
private int _currentId = 0; | ||
|
||
private void AddStudent(string firstName, string lastName, string major) | ||
{ | ||
_currentId++; | ||
|
||
Student student = new Student { StudentID = _currentId, FirstName = firstName, LastName = lastName, Major = major }; | ||
|
||
this.Add(student); | ||
} | ||
|
||
public TestStudents() | ||
{ | ||
AddStudent("Joe", "Doe", "Math"); | ||
AddStudent("Sonny", "Corleone", "Liberal Arts"); | ||
AddStudent("Johny", "Fontane", "Singing"); | ||
} | ||
|
||
public override string? ToString() | ||
{ | ||
return TheSelectedItem?.ToString() ?? base.ToString(); | ||
} | ||
} | ||
} |
Oops, something went wrong.