prismlibrary / prism-samples-wpf Goto Github PK
View Code? Open in Web Editor NEWSamples that demonstrate how to use various Prism features with WPF
License: MIT License
Samples that demonstrate how to use various Prism features with WPF
License: MIT License
I get the following error.
CS1593 Delegate 'Expression<Func>' does not take 1 arguments
I expect something has changed in version V6.3 the sample does works is V6.2.
According to this blog post the parameter in the method ObservesCanExecute needs to be removed.
http://brianlagunas.com/prism-6-3-release/
404?
Hi,
Brand new user here trying the Prism framework for the first time. Cloned the Prism-Samples-Wpf solution. Unfortunately, when trying to build, getting the missing reference errors about the System.ObjectModel and System.Runtime assemblies.
After adding those assembly references manually, getting the following error message: “Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.”
Quick search on Google indicates that perhaps Windows 8 at minimum is required. Building the project with Visual Studio 2013 Update 5 under Windows 7. Is Windows 8 or higher really required, or is something else amiss?
Thank you.
I was just checking new WPF PRISM example from here.
There is a project called UsingCompositeCommands.Core which is created PLC. By using short guide from here, I was able to build it as .NET Standard 2.0 and example works as well after .net framework version change.
Do you think this is the right way to do it for new projects as well ?
If you do, maybe we can update example too ;)
I have two questions about using InteractionRequest for modal dialog box. I hope they are included in the sample.
With Interactivity, I know how to center a dialog box to its immediate owner. In my case, the dialog box owner is no in the center of the Shell. And I need to center the dialog box to the Shell. I have spent some time on it, but still have no clue. Is it doable with Interactivity? Or I need a different way? TIA.
Sample-20, In MainWindow.xaml , i try to use following xaml code:
<Style TargetType="{x:Type TabItem}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type TabItem}">
<TextBlock Text="{Binding DataContext.Title, RelativeSource={ RelativeSource AncestorType={x:Type TabItem} } }" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
instead of the original code:
<Style TargetType="TabItem">
<Setter Property="Header" Value="{Binding DataContext.Title}" />
</Style>
But the binding is not working.
Am i missing anything?
Hi @austindimmer
i am beginer of Prism and Xamarin. i really need to implement "07-Modules - LoadManual" to our mobile application using Xamarin. i think it is possible to achieve but it difficult to me. how do you think about this?
Hi,
I have made a new WPF project, and implemented the same structure as you have for your hello world sample. My problem is in the module class' constructor when i set the regionManager parameter to the local field and try step out of the constructor, I get directed to a warning screen stating that the application is unable to locate the ServiceLocatorImplBase.cs file.
My platform target is Any CPU as it is a normal WPF project, and my target framework is 4.6.1.
Any plans on creating a ContosoCookbook app for wpf like the one for xamarin forms?
How could the first item in the ListBox be auto-selected when the ListBox ItemsSource has been updated?
Adding
SelectedItem="{Binding SelectedItemText, Mode=OneWay}"
to the ListBox doesn't work.
Calling
OnItemSelected(Items.ToArray());
in the MainWindowViewModel ctor doesn't set the ListBox selection to ItemList.SelectedItems[0].
Hello,
if you Update the packages to the newest version via NuGet-Packet-Manager, you cannot build the Projects anymore.
Can you help?
Bootstrapper seems to be an abstract class so when I copy this code:
Prism-Samples-Wpf/1-BootstrapperShell/BootstrapperShell/App.xaml.cs
It fails to compile - am I misunderstanding something?
Thx
Hi,
I created a solution file that has all the examples in it. I would love to create a branch and push it so you can review it. It's easier than having to open a lot of solutions.
Hi guys,
great work with prism 6. I think the navigation quick start is kinda complicated with the modules in there and MEF. Is it possible to create a much simpler sample that one could learn from. I have the quick start in visual studio and I can make sense of some of it but the rest just seems different from when I don't have modularity enabled with Unity and just have 5 views I want to navigate to for example. Can you guys help with that? Hope it ain't too much to ask.
God bless.
Is there a working sample of StockTrader RI with Unity instead of MEF ?
If not, I would like to contribute this work.
https://github.com/mjeson/PrismSample-StockTraderRI-Unity
Most of the functionalities compile and run, but the Pie Chart and News popup do not show up yet. Hope to get help from this Prism community to have them working.
Hi
I am getting an error when building this project, but I can't find the cause.
https://github.com/PrismLibrary/Prism-Samples-Wpf/tree/master/12-UsingCompositeCommands
Error messages :
Severity Code Description Project File Line Suppression State
Error The package reference 'Prism.Core' must have a version defined in 'C:\Users\kaki1\source\repos\Prism-Samples-Wpf\Packages.props'. UsingCompositeCommands.Core C:\Users\kaki1\source\repos\Prism-Samples-Wpf\12-UsingCompositeCommands\UsingCompositeCommands.Core\UsingCompositeCommands.Core.csproj 1
Error The package reference 'Prism.Wpf' must have a version defined in 'C:\Users\kaki1\source\repos\Prism-Samples-Wpf\Packages.props'. ModuleA C:\Users\kaki1\source\repos\Prism-Samples-Wpf\12-UsingCompositeCommands\ModuleA\ModuleA.csproj 1
Steps 1 through 11 were built normally without errors.
My environment
Windows 10 version 2004
Visual Studio 2019 version 16.7.2
Is your feature request related to a problem? Please describe.
I am missing a sample or some documentation explaining the correct way to handle this. I want to set up a .NET Core WPF application which uses Prism and whose Lifetime / DI / Configuration is controlled (or supported) by a Generic Host.
In my case I am utilizing DryIoC as my ioc container of choice.
Right now WPF does not do a great job of using newer framework features, there are some open issues on GH like dotnet/wpf:499. So even if the WPF integration will not be perfect, some aspects can already be put to good use: IoC, Configuration and Hosted Services for background tasks.
Describe the solution you'd like
Clear guidelines for bootstrapping an application using a Generic Host, sample included.
I am having trouble finding definitive information on instantiating the IoC container myself. There is a hook that seems to be doing that - CreateContainerExtension()
. Is this the correct way to go about it? If yes, is its intended use documented and if not - can we improve the documentation?
Describe alternatives you've considered
I managed to get things going with a couple of extra lines, but I'm sure that there are better ways to go about that (eg utilizing the aforementioned CreateContainerExtension
method).
Additional dependencies:
Microsoft.Extensions.Hosting
- this dependency is for the generic host feature.DryIoc.Microsoft.DependencyInjection
- package with extension methods for the dryioc adapter, usually used in the context of ASPNET Core.The App.xaml.cs actually looks alright, services can be registered as usual and resolved via base.Container
and via _host.Services
since im basically just adding more registrations to the instantiated container.
// App.xaml.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<ServiceA>();
}
protected override Window CreateShell()
{
_host = new HostBuilder()
.ConfigureServices(x =>
{
x.AddTransient<ServiceB>();
})
.UseServiceProviderFactory(new DryIocServiceProviderFactory(Container))
.Build();
_host.Start();
// ServiceA and ServiceB can be resolved here.
return _host.Services.GetService<MainWindow>();
}
While implementing the DryIoC Service Provider Factory it became obvious that I'm going down the wrong path. As you will see, I am taking the instantiated container and casting it to the known underlying type. Normally you would new up a container in CreateBuilder
so this current implementation feels wrong.
// DryIocServiceProviderFactory.cs
internal class DryIocServiceProviderFactory : IServiceProviderFactory<IContainer>
{
private readonly DryIocContainerExtension _containerProvider;
public DryIocServiceProviderFactory(IContainerProvider containerProvider)
{
// I should not be doing this..
_containerProvider = containerProvider as DryIocContainerExtension;
}
public IContainer CreateBuilder(IServiceCollection services)
{
return _containerProvider.Instance.WithDependencyInjectionAdapter(services);
}
public IServiceProvider CreateServiceProvider(IContainer containerBuilder)
{
return containerBuilder.Resolve<IServiceProvider>();
}
}
Describe suggestions on how to achieve the feature
So if I am correct, I need to somehow use the CreateContainerExtension()
method.
The following does not work, Prism services are missing from the container and cannot be resolved.
protected override IContainerExtension CreateContainerExtension()
{
return new DryIocContainerExtension(new DryIoc.Container());
}
I thought that these would get registered in the container I return from this method.
Hopefully I did not miss anything obvious in the documentation, I searched but found nothing. I would love to contribute to the project and push such a sample, but before doing that I need a bit of hand holding. Thanks!
Open the project "07-Modules - Directory" with VS2017,
Bulid - Rebuild solution,
The Output window display :
error MSB3073: The command "xcopy "D:\Projects\Prism-Samples-Wpf\07-Modules - Directory\ModuleA\bin\Debug\ModuleA*.dll" "D:\Projects\Prism-Samples-Wpf\07-Modules - Directory\Modulesbin\Debug\Modules" /Y /S" exited with code 2.
1.Modulesbin should be Modules\bin
2.exited with code 2 because Debug\Modules directory does not exist,
I change
xcopy "$(TargetDir)$(TargetName)*$(TargetExt)" "$(SolutionDir)$(SolutionName)$(OutDir)Modules" /Y /S
to
xcopy "$(TargetDir)$(TargetName)*$(TargetExt)" "$(SolutionDir)$(SolutionName)/$(OutDir)Modules" /I /Y /S
it works.
Is it possible to have an example how to correctly create an InteractionRequest with an injected view ([Export]) and injected model (prism:ViewModelLocator.AutoWireViewModel="True") ?
I'm interested in updating these samples to .NET Core 3.1.
I already have a sample application out there showing how to do a lot of these features in .NET Core.
If you want to preserve these demos for .NET Framework developers, would you be willing to take contributions to a new repository?
Hello team,
We are using Prism interactivity feature.Everthing is fine.
But the issue is we should allow user to resize the window.
Is it possible to accomplish it without deep or hard code :) ?
Best regards
We have an legacy WPF application that's using WPF Prism 5.x, now we need to upgrade the Prism to 8.x.
The app has reference of Microsoft.Practices.Prism.Interactivity.InteractionRequest which implements INotification and IInteractionRequest.
Can you please help me with alternative implementation in Prism 8.x?
Below is the implementation using Prism 5.x.
View Model:
namespace InteractionRequest.Example
{
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
public class InteractionRequestViewModel
{
public InteractionRequestViewModel()
{
this.ExceptionRequest = new InteractionRequest<ExceptionNotification>();
}
public InteractionRequest<ExceptionNotification> ExceptionRequest { get; private set; }
public void HandlerOnOnExceptionHandled()
{
this.ExceptionRequest.Raise(new ExceptionNotification
{
Title = "Unhandled Exception",
Content = "Divided by zero exception",
DebugInformation = "Divided by zero exception",
});
}
}
}
View:
<Window x:Class="InteractionRequest.Example.InteractionRequestView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:si="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
Title="MainWindow" Height="250" Width="300" MinHeight="200">
<i:Interaction.Triggers>
<!-- Trigger listening for the "Raised" event on the source object (of type IInteractionRequest) -->
<i:EventTrigger EventName="Raised" SourceObject="{Binding ExceptionRequest}">
<i:EventTrigger.Actions>
<interactions:ExceptionAction />
</i:EventTrigger.Actions>
</i:EventTrigger>
</i:Interaction.Triggers>
</Window>
Notification:
namespace InteractionRequest.Example
{
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
public class ExceptionNotification : Notification
{
public string DebugInformation { get; set; }
}
}
Action:
namespace InteractionRequest.Example
{
using System.Windows;
using System.Windows.Interactivity;
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
public class ExceptionAction : TriggerAction<FrameworkElement>
{
#region Methods
protected override void Invoke(object parameter)
{
var args = parameter as InteractionRequestedEventArgs;
if (args == null)
{
return;
}
var content = args.Context as ExceptionNotification;
if (content == null)
{
return;
}
var window = new ExceptionWindow(content));
window.ShowDialog();
}
#endregion Methods
}
}
I have just added a few more regions to the MainWindow in the Hello World sample. The regions are TopRegion, LeftRegion, MainRegion (as before), RightRegion and BottomRegion, and placed "Hello World" in the TopRegion. The idea is that this structure may remain relative stable and recognizable as more advanced samples are developed later. My first and very, very tiny contribution to this project may be to share a zip-file containing this solution with you.
HI, for Prism every example is available with unity. but the View Switching example is using MEF only. can this be available with unity as well.
Regards,
Kamlendra
It is necessary to give an sample of using that new method, and in particular how to test it.
It may be changed to the following code:
<UserControl
x:Class="ModuleA.Views.PersonList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i1="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">
<UserControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Header" Value="{Binding DataContext.SelectedPerson.FirstName}" />
</Style>
</UserControl.Resources>
<Grid
x:Name="LayoutRoot"
Margin="10"
Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListBox x:Name="_listOfPeople" ItemsSource="{Binding People}">
<i1:Interaction.Triggers>
<i1:EventTrigger EventName="SelectionChanged">
<prism:InvokeCommandAction Command="{Binding PersonSelectedCommand}" CommandParameter="{Binding SelectedItem, ElementName=_listOfPeople}" />
</i1:EventTrigger>
</i1:Interaction.Triggers>
</ListBox>
<TabControl
Grid.Row="1"
Margin="10"
prism:RegionManager.RegionName="PersonDetailsRegion" />
</Grid>
</UserControl>
The modification:
xmlns:i1="http://schemas.microsoft.com/xaml/behaviors"
<i1:Interaction.Triggers>
<i1:EventTrigger EventName="SelectionChanged">
<prism:InvokeCommandAction Command="{Binding PersonSelectedCommand}" CommandParameter="{Binding SelectedItem, ElementName=_listOfPeople}" />
</i1:EventTrigger>
</i1:Interaction.Triggers>
Hi all,
There is an introduction about dialog service on the PrismLibrary but no sample here.
I want to provide a dialog sample. How can I do that? Which number should I name for the folder?
Thanks.
ViewSwitchingNavigation sample project includes heavy use the old APM pattern.
Who will start now to learn about IAsyncResult, just because he want to learn about prism?
any demo like View-Switching Navigation
before is more complex , but it was deleted ?
It would be nice if you provide a Undo/Redo sample.
I am a novice, in 13-IActiveAwareCommands, I don't know how to create it .Was it created by yourself or by The Prism Template Pack ?I did not find it with vs2019.
Before Prism 7.0 I can use state-based navigation to switch view state to Navigate to ListView's Item, but after Prism 7.0 I can't see that any more, so what's the correct way to Navigate when I click a ListView's item(the item is a ViewModel alreay exist so I can't use view-based Navigation)
I would like to know how to implement the RegionBehaviors. Could you please raise the sample code for RegionBehavior?
I want to call window but all examples work with userControl.
I'm using BootstrapperShell and when i call the form from my Ribbon menu, loading grid working really slow but in the main page is work well.
I tested by calling window its work as well too. but i can't embed the window in the main form and it does not work.
in this code i have WindowKostenstelle this form az window, not user control:
_regionManager.RequestNavigate(RegionNames.ContentRegionName, "WindowKostenstelle" );
The new version have introduced some breaking new feature and the samples need to be updated to run.
It is very useful set of code.
Despite a good documentation, this samples really saves developers time. It shouldn't be abandoned.
I couldn't find another way to say 'thanks', so I created this issue :-)
I could not find sample project for ‘Registering Modules Using a XAML file’ within ‘Prism-Samples-Wpf’. Include a sample project for ‘Registering Modules Using a XAML file’.
The DemoApplication ViewSwitchingNavigation does not build.
Severity Code Description Project File Line Suppression State
Error Resource file "obj\x86\Debug\View_Switching.AcceptanceTest.TestData.ControlIdentifiers.resources" has an invalid name.
The item metadata "%(FullPath)" cannot be applied to the path "obj\x86\Debug\View_Switching.AcceptanceTest.TestData.ControlIdentifiers.resources". obj\x86\Debug\View_Switching.AcceptanceTest.TestData.ControlIdentifiers.resources
View-Switching.AcceptanceTest
Build configuration X86
Windows-7 with VS Enterprise 2015
Problem is caused by 260 CHAR limitation in windows-pathlengths
Build error occurs when project is hosted in path
L:\wrk\OLI3\VS2015.CSharp.Dev\VS2015\C#\20161207_mvvm_Prisma\Prism-Samples-Wpf-master\View-Switching Navigation_Desktop
Build error nomore occurs with shortened path
L:\VS2015\Modularity
Problem
Obviously the demo program does not handle the possible problems with overlong pahtnames. Itself it uses quite long sub-pathnames. The builderror is in no way helpful or indicating how to correct the situation to avoid failure. I found the solution by pure intution. Such severe failures shouldn't be possible
in simple demo programs, that have a promotional and educational function.
The latest release with 7.0 and Unity does not work with a bootstrapper.
this does not compile
protected override DependencyObject CreateShell()
{
return Container.Resolve();
}
I was looking for Custom Requests with IDialogService
. The samples 25 to 29 are using INotification
.
Then I saw this page and achieved my goal.
https://prismlibrary.com/docs/wpf/dialog-service.html
I'm sure you are aware of this but I just want to mention. Ready to run samples are nice to get it the big picture.
Is there a similar sample program
in PRISM 7.0 UnityBootstrapper
is Obsolete. so How can we load the module from app.config by using internal partial class App : PrismApplication
class.
I'm brand new to PRISM and Unity and I'm trying to work my way through this process, please excuse the basic questions. I download the PrismDemo code from Brian Lagunas' "MVVM Made Simple with Prism" which used Prism 6. Using 'Manage NuGet Packages" in Visual Studio, I updated all the Prism and Unity Libraries. In the Bootstrapper.cs it says theUnityBootstrapper Base Class is obsolete, got it. I change the base class from UnityBootstrapper to PrismApplication, done. It also says "This will require updating the App.xaml and App.xaml.cs files", however I can't find any documentation that tells me what needs to be changed. Here in the Prism-Samples-Wpf, in 01-BoostrapperShell, still uses UnityBootstrapper with the same warning/information message. I know it will still work, but I would prefer not to use obsolete objects and use Prism 7 as it is intended to be used. Can someone point me to a resource, YouTube or blog post that will help me get pass this. Thanks in Advance.
I would like to add my two cents (maybe one only)...
I propose to modify the postbuild macro in the project "07-Modules - Directory" with this one:
xcopy "$(TargetDir)$(TargetName)*$(TargetExt)" "$(SolutionDir)$(SolutionName)$(OutDir)Modules" /Y /S
In this way, you can copy with the module .DLL also the localization satellites .DLL; you don't need to manually copy them in the "Modules" directory, and all the culture changes get instantly applied in the modules.
The final result will be, for example (for italian localization): module .DLLs in Modules dir, subdir "it-IT" containing the italian localization DLLs for all the modules.
Daniele Prevato
Is there any way to navigate with Prism (using RegionManager.RequestNavigate) and prevent prism pushing the view in navigation History.
I want Navigate from ViewA to ViewB and From ViewB To ViewC but when navigating from A to B i won't historisize the viewB , So when i call GoBack from ViewC then ViewA appears because the ViewB not exist in History of navigation.
Exemple :
I am in ViewA
Call RequestNavigate(ViewB) -----> Show ViewB
Call RequestNavigateWithoutHistorisize(ViewC) ----> Show ViewC
Call GoBack() -------> Show ViewA
Thanks
Hi,
There is a little mistake in Post-build event command line
Original line is :
xcopy "$(TargetDir)$(TargetName)*$(TargetExt)" "$(SolutionDir)$(SolutionName)$(OutDir)Modules" /Y /S
The fix is :
xcopy "$(TargetDir)$(TargetName)*$(TargetExt)" "$(SolutionDir)$(SolutionName)$(OutDir)Modules" /Y /S
Regards
I try to build Prism-Samples-Wpf using Visual studio community 2019.
It cannot find CommonServiceLocator file. Restoring nuggets or manually removing
and adding Prim.Wpf don't help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.