Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all 1760 articles
Browse latest View live

New Post: Validation on ComboBox Issue

$
0
0
I have just been looking at this issue myself, as I wish to do validation on a ComboBox whilst still using the convention based binding.

Having had a dig through the Caliburn.Micro code, the issue seems to be that the ConfigureSelectedItem routine calls BindingOperations.SetBinding directly rather than calling the SetBinding Action on the ConventionManager which applies all the default validation rules and so forth. I'm not sure if there was a reason for this, perhaps someone with a better understanding of the framework could answer that.

What it does mean is that overriding ApplyValidation has no effect as it is never called.

New Post: 3D Viewport Control

$
0
0
Framework 4.0
Is the WPF 3DViewport control supported in CM? Is there a simple sample of the use of the 3DViewport with Caliburn Micro?

New Post: Proper way to bind to usercontrol? I get BindingExpression errors in output window but the binding works fine in runtime

$
0
0
i have the following xaml:

<UserControls:MaintenancePanel cal:Bind.Model="{Binding MyPanelInfo}" Margin="5,5,5,5"/>

and I have a viewmodel class called MaintenanceViewModel which contains a property called MyPanelInfo

inside the usercontrol, i have bindings to properties that MyPanelInfo instance contains. the binding works fine in runtime but i get this annoying error in the output window that i'd like to resolve for the sake of resolving it.

System.Windows.Data Error: 40 : BindingExpression path error: 'DeviceName' property not found on 'object' ''MaintenanceViewModel' (HashCode=16653192)'. BindingExpression:Path=DeviceName; DataItem='MaintenanceViewModel' (HashCode=16653192); target element is 'GroupBox' (Name=''); target property is 'Header' (type 'Object')

New Post: wp7 - webbrowser control

New Post: How to Bind data with grid using Calibrum

$
0
0
Can u please provide code for binding the data with grid in Calibrum.I have data in list which is come from WCF service.Now i want to bind tht data with grid.

New Post: How to use CM without "Application"-Object

$
0
0
ssak32 wrote:
Hi,
I am Novice to CM. I am in the same situation when Akkarin started this discussion and Eisenberg's reply to use "new Bootstrapper(false)". Well, I guess this was working with older versions of CM, but now the current version what I am using is "v1.5.2.0" and this does not support "new Bootstrapper(false)" any more.

Background: I am intending to introduce CM in an Class Library project under an existing application which does not use CM (A simple WPF application with MVVM).

Anybody could help me with a suggestion how to counter attack this problem. A demo code would be an added advantage.

Thanks in advance...
Add the following constructor to your AppBootstrapper class:
public AppBootstrapper() : base(false) { }
and start your library by:
new YourNamespace.AppBootstrapper().Start();
var w = IoC.Get<IWindowManager>();
return w.ShowDialog(new YourNamespace.ViewModels.MainWindowViewModel());

New Post: Conventions not working inside Hub

$
0
0
Hi,
I use Caliburn.Micro in a Win 8.1 app and I always take advantage of conventions,
and I noticed that when I place my controls inside a Hub control, the conventions does not work anymore..

Simple example:
I have a button named MyButton, and in the ViewModel I have a void method named MyButton, and the convention works..

If I move that button inside a HubSection, in its DataTemplate, the convention does not work anymore!
And this is the behaviour with all the controls,

Why this? Can you help me?

New Post: Setting MaximumMessageReceiveSize

$
0
0
Hi,

I am developing a windows store app in xaml with Caliburn Micro framework. Here I am getting all the data from a Webservice. There is a page where one can edit their post in the project. TO enable editing,I need to get data from the webservice. It is working perfectly when I am trying to edit data without attachment. But if there is a post with attachemnt,my app can't retrieve data from service. It is giving me

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

this exception.

My code snippet is
----CS Page---

mbmessage = await MessageManager.getThreadData(id);

----getThreadData() method--

public static async Task<MBMessage> getThreadData(long message_id)
   {

     return LearnNET2_DataModel.Manager.Search.GetDeserializedDataForEditThread(await LN2ServiceWrapper.get().getForumMessageAsync(token,scrnm,grp_id,message_id));


   }
here the getForumMessageAsync method is calling the webservice and fetching data.

I do not have any app.config file in client side. I can not even add it. So please guys help me solve this problem as soon as possible.

Thanks in advance.

New Post: Event Aggregator with multiple views

$
0
0
I'm trying to build this project using Caliburn for the first time (and also the MEF structure, that I didn't fully understand).

I need to use both the Conductor and the EventAggregator. The Conductor because i have an AppViewModel which "displays" 3 buttons that move the user to 3 different views (UserControls inside AppView).

And I need the EventAggregator because one of these 3 views has a button inside of it that must load 4th view (that must be a Window I think, not a UserControl, because it has to be full screen). So I thought that when the user click this button inside the 3 view (UserControl inside AppView) a Message can be sent top the listener (that should be the AppViewModel), and this one should ActivateItem(4th vm).

I don't why but even following the examples of the projects of Caliburn my message does not reach the AppViewModel.

This is my bootstrapper:
public class AppBootstrapper : Bootstrapper<AppViewModel>
    {
        private CompositionContainer container;

        protected override void Configure()
        {
            container = new CompositionContainer(new AggregateCatalog(AssemblySource.Instance.Select(x =>
                new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()));

            CompositionBatch batch = new CompositionBatch();

            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());
            batch.AddExportedValue(container);

            container.Compose(batch);
        }

        protected override object GetInstance(Type serviceType, string key)
        {
            string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;
            var exports = container.GetExportedValues<object>(contract);

            if (exports.Any())
                return exports.First();

            throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract));
        }

        protected override IEnumerable<object> GetAllInstances(Type serviceType)
        {
            return container.GetExportedValues<object>(AttributedModelServices.GetContractName(serviceType));
        }

        protected override void BuildUp(object instance)
        {
            container.SatisfyImportsOnce(instance);
        }

        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            DisplayRootViewFor<AppViewModel>();
        }
    }
This is the AppViewModel:
[Export (typeof(AppViewModel))]
public class AppViewModel : Conductor<object>, IHandle<ChangeViewEvent>
{
    [ImportingConstructor]
    public AppViewModel(IEventAggregator events)
    {
        events.Subscribe(this);
        ActivateItem(new MainViewModel());            
    }

    public void GoToPatientsManager()
    {
        ActivateItem(new PatientsManagerViewModel(new WindowManager(), new EventAggregator()));
    }

    public void GoToTestManager()
    {
        ActivateItem(new TestManagerViewModel(new WindowManager()));
    }

    public void GoToResultsManager()
    {
        ActivateItem(new MainViewModel());
    }

    public void Handle(ChangeViewEvent message)
    {
        switch (message.ViewName)
        {
            case "TestManager" :
                GoToTestManager();
                break;
        }
    }
}
And this is the view model that should launch the request for loading the 4th vm
 [Export(typeof(PatientsManagerViewModel))]
    public class PatientsManagerViewModel : Screen
    {
        private readonly IWindowManager _windowManager;
        private readonly IEventAggregator eventAggregator;

        [ImportingConstructor]
        public PatientsManagerViewModel(IWindowManager windowManager, IEventAggregator eventAggregator)
        {
            _windowManager = windowManager;
            this.eventAggregator = eventAggregator;
        }

        #region Methods

        public void ShowFakeMessage()
        {
            dynamic settings = new ExpandoObject();
            settings.Placement = PlacementMode.Center;
            settings.PlacementTarget = GetView(null);

            var res = _windowManager.ShowDialog(new DeletePersonViewModel(), null, settings);

            if (res)
            {
                // The result of the dialog men. In this true case we'll use Linq to delete the entry from the database
                // using the dbContext
            }
        }

        public void GoToTestManager()
        {
            eventAggregator.Publish(new ChangeViewEvent("TestManager"));
        }

        #endregion
    }
It does not reach the Handle method of the AppViewModel.

Is these something wrong with the instances of the view models? I can't move forward from here...
Is it becasue i create a new Event Aggregator evrytime I ActivateItem the PatientsManagerViewModel?

Thank you...

New Post: DataGrid with Message.Attached on MouseDoubleClickEvent

$
0
0
Hello ,

I need the ability to double click on a row on a DataGrid and perform some action in my VM .

XAML :

<DataGrid cal:Message.Attach="[Event MouseDoubleClick] = [Action SomeAction($this)]">


this works fine and passes the current item when a row is double clicked , it also works if you have a SelectedItem and double click any other part of the DataGrid.

"$this - The actual ui element to which the action is attached. "

Why am i even getting the DataItem when double clicking and not an instance of DataGridRow ?

A answer to this , would also solve my problem since when receiving an Source other then DataGridRow .
i would igonre it.

thanks in advance .

New Post: ArgumentException Error - Value is not a hop source in the route.

$
0
0
I got the same error when I had a typo in my message attach
cal:Message.Attach="[Event Click] = [SelectBlah($souce,$datacontext)]"
For those that couldn't see it like I didn't, $source is spelt wrong.

New Post: Binding inside a Groupbox.Header?

New Post: How to use CM without "Application"-Object

$
0
0
ssak32,

You have to use the non-generic form of the bootstrapper, like so:
public class AppBootStrapper : BootstrapperBase
    {
        public AppBootStrapper() : base(false)
        {
        }

New Post: How to use CM without "Application"-Object

$
0
0
Indeed I did miss the part about version 1.5.2 removing that base constructor. Neither did I realize I was working with an old version.

Nice find on the solution, Pete

New Post: Keybinding Command/Action

$
0
0
Would this pattern work the same when using a UserControl and letting CM inject it into a window?

New Post: Is using this MVPVM pattern with Caliburn possible?

$
0
0
"MVP = MVVM they are almost completely synonymous with each other"

Actually, that statement could confuse the development community, I'd like to share some info....

The PresentationModel and MVVM are synonymous - John Gossman, founding father of MVVM, explains this in his “PresentationModel and WPF” blog entry at bit.ly/pFs6cV. Like Martin Fowler, he was careful not to overload terms. This effectively gives us a clear understanding of what MVVM is; it’s a “WPF-specific version of the PresentationModel pattern.”

The "Presentation model" exhibited exactly the problems that mugen_kanosei is discussing. Martin Fowler states the following on the topic:

"Directly updating the widgets like this is not part of Presentation Model, which is why the visual works application model isn't truly a Presentation Model. This need to manipulate the widgets directly was seen by many as a bit of dirty work-around and helped develop the Model-View-Presenter approach."

So MVP is the evolution of Presentation Model (aka MVVM).

Ref: http://martinfowler.com/eaaDev/uiArchs.html

Best regards - Bill

Commented Unassigned: ActionMessage Not in Namespace [358]

$
0
0
I am using VS2013 to create a WPF 45 project. Everything works fine except for the ActionMessage. I have tried setting up the namespace two ways:

1. xmlns:cal="http://www.caliburnproject.org"
2. xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"

Then, setting up a button to use an Action using either of 2 methods:

Method 1:
```
<Button Content="{Binding ConfirmButtonText}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cal:ActionMessage MethodName="ConfirmCommand"></cal:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
```
Method 2:
```
<Button Content="{Binding ConfirmButtonText}"
cal:Message.Attach="[Event Click] = [Action ConfirmCommand()]" />
```

In all cases, the code runs as designed. However the page will not display properly in Blend or the VS designer because of an "Invalid Markup" error:

* The name "Message" does not exist in the namespace (whichever is referenced by cal:).
* The name "ActionMessage" does not exist in the namespace (whichever is referenced by cal:)

I want to use this product, but this is a showstopper. If the forms are not compatible with the designer or Blend, then I must abandon this otherwise awesome library.

Can anyone help?
Comments: I've seen the same issue as the reporter when using CM from a zip file and adding a reference. When I switched to the NuGet package the issue disappeared.

New Post: MUI + Caliburn.Micro Navigation

$
0
0

Question

Hi,

In my current project I am using MUI, Caliburn.Micro & Ninject. But I have some issues:

1) How can I show WarehouseProductCategoriesPageViewModel form ShellPageViewModel from code?
        public ShellPageViewModel()
        {
            // TODO: Instance of WarehouseProductCategoriesPageViewModel is created but View is not showed.
            ActivateItem(new WarehouseProductCategoriesPageViewModel());            
        }
2) How can I navigate to UpdateCategoryPageViewModel from WarehouseProductCategories?
    public class WarehouseProductCategoriesPageViewModel : Screen
    {       
        // TODO: How navigate to Update Categoy Page?       
        public void GoToUpdateCategoryPage()
        {
            // Some code...
            // Navigation to Update Category Page
        }
    }
P.S. All questions are written in code.

I'll be very thankful to somebody who can help me.

Best Regards,
Serhiy

Source Code

    APPLICATION BOOTSTRAPPER

    public class AppBootstrapper : BootstrapperBase
    {
        private IKernel _kernel;
        public AppBootstrapper()
        {
            Start();
        }

        protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            DisplayRootViewFor<IShellPage>();
        }

        private void ConfigureConvensions()
        {
            var tmc = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViewModels = "Pages",
            };

            ViewLocator.ConfigureTypeMappings(tmc);
            ViewModelLocator.ConfigureTypeMappings(tmc);
        }

        private void ConfigureCompositionRoot()
        {
            _kernel = new StandardKernel();
            _kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
            _kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
            _kernel.Bind<IShellPage>().To<ShellPageViewModel>().InSingletonScope();
        }

        protected override void Configure()
        {
            ConfigureConvensions();
            ConfigureCompositionRoot();
        }

        protected override object GetInstance(Type service, string key)
        {
            Contract.Requires<ArgumentNullException>(service.IsNotNull());

            return _kernel.Get(service);
        }

        protected override IEnumerable<object> GetAllInstances(Type service)
        {
            return _kernel.GetAll(service);
        }

        protected override void BuildUp(object instance)
        {
            Contract.Requires<ArgumentNullException>(instance.IsNotNull());

            _kernel.Inject(instance);
        }

        protected override void OnExit(object sender, EventArgs e)
        {
            if (_kernel.IsNotNull())
                _kernel.Dispose();

            base.OnExit(sender, e);
        }
    }   

    
    SHELL PAGE VIEWMODEL
    
    public interface IShellPage { }

    public class ShellPageViewModel : Conductor<IScreen>.Collection.OneActive, IShellPage
    {
        public ShellPageViewModel()
        {
            // TODO: Instance of WarehouseProductCategoriesPageViewModel is created but View is not showed.
            ActivateItem(new WarehouseProductCategoriesPageViewModel());            
        }
    }
    
    SHELL PAGE VIEW

    <mui:ModernWindow x:Class="Haircut.Desktop.Views.ShellPageView"        
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                    
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                          
                  xmlns:mui="http://firstfloorsoftware.com/ModernUI"        
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"             
                  mc:Ignorable="d"                          
                  ContentLoader="{StaticResource CaliburnContentLoader}">            
        <mui:ModernWindow.MenuLinkGroups>                
            <mui:LinkGroup DisplayName="Warehouse">            
                <mui:LinkGroup.Links>                
                    <mui:Link DisplayName="Product categories" Source="../Views/Warehouse/WarehouseProductCategoriesPageView.xaml" />
                </mui:LinkGroup.Links>
            </mui:LinkGroup>
        </mui:ModernWindow.MenuLinkGroups>        
    </mui:ModernWindow>


    WAREHOUSE PRODUCT CATEGORIES PAGE VIEWMODEL 
    
    public class WarehouseProductCategoriesPageViewModel : Screen
    {       
        // TODO: How navigate to Update Categoy Page?       
        public void GoToUpdateCategoryPage()
        {
            // Some code...
            // Navigation to Update Category Page
        }
    }

New Post: Update While Show Dialog is Open

$
0
0
I have a scenario and wanted to know if its possible to do something while the ShowDialog is open. Below is the current code I have:
        this.NumericViewModel = new NumericKeypadViewModel(this.Quantity);
        bool? dialogResult = this.windowManager.ShowDialog(this.NumericViewModel, null, settings);

        if (dialogResult == true)
        {
            this.Quantity = this.NumericViewModel.InputDataEntered; 
        }
However I want to update Quantity every time InputDataEntered from NumericViewModel changes while the dailog is open. Is it possible to do that?

Created Unassigned: Binding with Caliburn.Micro Failing [362]

$
0
0
I have a `MessageBoxView` and an associated `MessageBoxViewModel` class, as shown below

public class MessageBoxViewModel : DialogViewModel<MessageDialogResult> { ... }

where

public abstract class DialogViewModel<TResult> : PropertyChangedBase { ... }

In my `MessageBoxView` XAML I am attempting to bind to some properties within the `MessageBoxViewModel` class. However, using Snoop I can see that the binding is failing. the stack trace/binding error is showing:

>System.Windows.Data Error: 40 : BindingExpression path error: 'AffirmativeButtonText' property not found on 'object' ''ShellViewModel' (HashCode=19096940)'. BindingExpression:Path=AffirmativeButtonText; DataItem='ShellViewModel' (HashCode=19096940); target element is 'Button' (Name='AffirmativeButton'); target property is 'Content' (type 'Object')

This view is for a dialog box, so I do not want this to inherit from IScreen. How can I get Caliburn.Micro to bind to properties in the associated view model?

Thanks for your time.
Viewing all 1760 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>