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

New Post: CM 1.4: DisplayRootViewFor works but DisplayRootView cannot find MenuViewModel

$
0
0

DisplayRootView<MenuView>() caanot find the matching view model MenuViewModel.

While DisplayRootViewFor<MenuViewModel> can find the appopreate view MenuView. Can't figure out what i'm missing.

I'm using the boostrapper from the HelloWinRT sample project.

Cheer


Commented Issue: winrt: DisplayRootViewFor works, DisplayRootView does not [262]

$
0
0
DisplayRootView<MenuView>() does not find the matching view model MenuViewModel.

Using DisplayRootViewFor<MenuViewModel> does find the appopreate view.. can't figure out what i'm missing.

I'm using the boostrapper from the sample project.

Cheers
Comments: Please remove, should be placed in Discussions.

New Post: [Caliburn Micro] How to bind the HyperLink of click event in Caliburn.Micro

New Post: How to persist caliburn micro app size?

$
0
0

I've been fighting my way through this same issue, and I finally got this to work by adding one line of code to the above snippet:

protectedoverridevoid OnStartup(object sender, StartupEventArgs e) 
{
base.OnStartup(sender, e);

Application.Current.MainWindow.SizeToContent = SizeToContent.Manual; // Enables Width/Height to be set explicitly Application.Current.MainWindow.Left = 10; // Works! Application.Current.MainWindow.Top = 10; // Works! Application.Current.MainWindow.Width = 500; // Works now! Application.Current.MainWindow.Height = 350; // Works now! }

New Post: Calling Parent VM in ItemsControl

$
0
0

There's this example from the Nuts'n'Bolts series, however it deals with the item being a DataTemplate. I'd like to keep things separate with a viewmodel, which works fine, but apparently not with Actions. How would I do "Remove($dataContext)" if the ItemTemplate were to be a separate View?

<UserControlx:Class="Caliburn.Micro.BubblingAction.ShellView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:cal="http://www.caliburnproject.org"><StackPanel><ItemsControlx:Name="Items"><ItemsControl.ItemTemplate><DataTemplate><StackPanelOrientation="Horizontal"><ButtonContent="Remove"cal:Message.Attach="Remove($dataContext)"/><TextBlockText="{Binding Id}"/></StackPanel></DataTemplate></ItemsControl.ItemTemplate></ItemsControl><ButtonContent="Add"cal:Message.Attach="Add"/></StackPanel></UserControl>

New Post: Change Page and Update Control from property

$
0
0
I'm Click Button and changing page in tabcontrol not update control from property,
Please help me.

ShellViewModel.cs

        [ImportingConstructor]public ShellViewModel(IEventAggregator eventAggregator,Page1ViewModel page1,Page2ViewModel page2)
        {
            EventAggregator = eventAggregator;

            Items.Add(page1);
            Items.Add(page2);

            ActivateItem(page1);
        }

 

Page1View.xaml

<Button x:Name="changebtn">

 

Page1ViewModel.cs

    [Export(typeof(Page1ViewModel))]publicclass Page1ViewModel : BaseViewModel
    {

        [ImportingConstructor]
        public Page1ViewModel()
        {
            DisplayName = "Page1";
        }

Page2View.xaml 

<CheckBox Content="Debug" IsChecked="{Binding Debug, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

 

Page2ViewModel.cs

    [Export(typeof(Page2ViewModel))]publicclass Page2ViewModel : BaseViewModel
    {

        [ImportingConstructor]
        public Page2ViewModel()
        {
            DisplayName = "Page2";
        }
   }
BaseViewModel.cs
publicvoid changebtn()
        {
            _debug = true;
        }privatestaticbool _debug;publicbool Debug
        {get { return _debug; }set
            {if (value.Equals(_debug)) return;
                _debug = value;
                NotifyOfPropertyChange(() => Debug);
            }
        }

New Post: Get ViewModel through IoC isssue

$
0
0

I'm newcommer in Caliburn.

You can see ViewModel code below.

[Export(typeof(CardValidatingViewModel))]publicclass CardValidatingViewModel
{
       [ImportingConstructor]public CardValidatingViewModel(string password)
        {            
        }
}

Associated view code:

  publicsealedpartialclass CardValidatingView {public CardValidatingView() { InitializeComponent(); CardValidatingViewModel viewModel = IoC.Get<CardValidatingViewModel>();; viewModel.ApplicationLaunchBranch(); } }

Namespaces are correct. IoC.Get() throws Exception from the code of Bootstrapper:

publicclass Bootstrapper : Bootstrapper<PrimaryLaunchViewModel>
    {private CompositionContainer container;protectedoverridevoid 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);
        }protectedoverrideobject GetInstance(Type serviceType, string key)
        {string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;var exports = container.GetExportedValues<object>(contract);if (exports.Count() > 0)
            {return exports.First();
            }thrownew Exception(string.Format("Could not locate any instances of contract {0}.", contract));
        }protectedoverride IEnumerable<object> GetAllInstances(Type serviceType)
        {return container.GetExportedValues<object>(AttributedModelServices.GetContractName(serviceType));
        }protectedoverridevoid BuildUp(object instance)
        {
            container.SatisfyImportsOnce(instance);
        }
    }
IoC.Get() could not locate any instances of ViewModel. Without IoC.Get() everything is fine.
I mean see the View. But I really need to get the ViewModel. What is the problem?

New Post: Get ViewModel through IoC isssue

$
0
0

In your importing constructor, you have a parameter that MEF can't resolve. It's looking in the container for a string part and doesn't find one. You typically inject  into the constructor using interfaces. There's a sample below. MEF will see that in order to create a CardValidatingViewModel it needs an IPassword object created first. It will look in the container and find one since we have a class that exports as an IPassword.

interface IPassword
{string password;
}

[Export(typeof(IPassword))]publicclass UserPassword : IPassword
{string password;
}

[Export(typeof(CardValidatingViewModel))]publicclass CardValidatingViewModel
{
   [ImportingConstructor]public CardValidatingViewModel(IPassword password)
   {//do something with password
   }
}

Commented Issue: ShareTarget Example (WinRT) [256]

$
0
0
Hello!

I found again a Issue in the ShareTarget WinRT Example and also in my Project.
If i try to share from e.g. IE ist works the first time.
If i want to share again, -> second Share Target Call, i got this Exception:
System.InvalidOperationException
Sequence contains more than one element in Caliburn.Micro.SimpleContainer

public object GetInstance(Type service, string key)
{
var entry = GetEntry(service, key);
if (entry != null)
{
return entry.Single()(this);
}
}


Can anyone help me to solve this Problem or take a look at this Issue!?

Comments: Does anyone have an idea how to solve this ...?

New Post: Get ViewModel through IoC isssue

$
0
0

Can you explain why you need to get the viewmodel from the IOC, in that nature?  Its kind of counter to what MEF and CM are normally doing behind the scenes.  CM will automatically bind the viewmodel to the view.  Therefore what you are doing with the IOC is actually causing some grief.  But what iamdragonwolf is correct it can't find the value of the parameter passed therefore MEF fails epically and doesn't give you a reason (one of the enhancements v2 was to bring better debug information). 

the viewmodel can do what you are attempting on the codebehind without having to pull from the IOC the object in question into the view.  look at the overrides for the viewmodel assuming its based off Screen type, you will have OnActivate, OnDeactivate, OnInitialize, etc, to do the things you need to without having tap IoC (which can actually lead to issues, example is your current error. ).

 

Morgan.

New Post: Get ViewModel through IoC isssue

$
0
0

Thank you very much guys! mvermef, thank you especially, now it's clear for me how to interact within viewmodel with view's lifecycle events.

New Post: Get ViewModel through IoC isssue

$
0
0

Hm... I faced the issue with OnActivated overriding or OnLoaded overriding. If I invoke required method I don't see the view. The method I invoke is a long running computational and I\O bound task. It's very uncommon situtation. Yes it's a long running task but I really don't need the separate thread for it. Otherwise the view is not displayed. I don't want use separete thread even from thread pool, because of need to syncronize many parts of code and because the machine is very slow despite of that we run WPF app on it.

New Post: CM 1.4: DisplayRootViewFor works but DisplayRootView cannot find MenuViewModel

$
0
0

Can you send me a sample of this not working to nigel.sampson@compiledexperience.com and I'll take a look.

New Post: Get ViewModel through IoC isssue

$
0
0

It all boils down to design decisions.  We have all been there, but if you are trying to keep the UI responsive then you are going to want to play with tasks or threads (framework version dependent), I have been learning RX a little to aid my UI responsiveness it might help you as well but then again it might not.  If its an application that you only use then that is one thing but if you are publishing for others then you might consider the above advice.

 Take a look at Dispatcher class in WPF or Execute.OnUIThread in CM

New Post: CM 1.4: DisplayRootViewFor works but DisplayRootView cannot find MenuViewModel

$
0
0

A common thing missing is the registration of the Frame control as the navigation service. In your App.xaml.cs you should have something like the following.

protectedoverridevoid PrepareViewFirst(Frame rootFrame)
{
    container.RegisterNavigationService(rootFrame);
}


New Post: CM 1.4: DisplayRootViewFor works but DisplayRootView cannot find MenuViewModel

$
0
0

As I was making a sample, I found the problem.

When adding a new XAML page to your project, the default DataContext is set like this

DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"

In some way, the ViewModel could not be located when the DataContext is already set? 

Thanks for you help Nigel!

Created Issue: Windows Phone 8 Panorama issue [263]

$
0
0
We're currently "porting" our existing app that uses caliburn to WP8. Most of the things are working as it used to but one strange thing occurred. In app with panorama layout that uses AllActive as base class for view model SelectedChange event subscribed to panorama "Items" in code behind (xaml.cs) does not fire but SelectedItem in view model works good. Do you know why this event is eaten or does not fire at all in this configuration?

There is other issue is that SelectedItem is Microsoft.Phone.Controls.PanoramaItem for the first time and after swipe it changes to exact panorama item view model.

Here is link for sample project http://db.tt/jPzJN8dh there is also hold event added on Items to prove that other events works.

New Post: Shell.Dialogs.ShowDialog() Disables other controls on shell - how to intercept

$
0
0

I have a Shell that has a Dialogs (IDialogManager - implemented by DialogConductor. I have some buttons on the Shell that I need to remain active when a dialog is shown.

I realise that the point of a modal dialog is that you have to deal with IT and only IT until finished, but I was wondering if there was some way to intercept and allow the buttons on the Shell to remain active?

The reason why is because this button invokes the TextInputPanel (Virtual Keyboard) which itself may be needed by the dialog.

Thanks,
Jaans 

New Post: WinRT and ViewModel-first: XAML is not enough!

$
0
0

After some hours of head scratching and debugging, I have finally managed to successfully run a simple ViewModel-first Caliburn application for WinRT!

I thought I'd share my experiences in case it can be of help to someone, and also in case someone knows a better workaround than mine.

Initially, I created a very simple MVVM app, button and a text box, and followed the instructions on this page to set up the App.xaml and App.xaml.cs files.

Initially I set up my application as a View-first application, and it ran without problems. Next, I followed the instructions for the ViewModel-first approach (removePrepareViewFirst override and use DisplayRootViewFor in OnLaunched). However, when I then ran the application, I only faced the following message:

Cannot find view for MyApplication.ViewModels.ShellViewModel

After some "serious" debugging I managed to find the root cause: I had removed theShellView.xaml.cs file! As a consequence of this, the ShellView class was not included in the assembly and could not be found by theViewLocator.

My workaround to this failure was to add a dummy ShellView.xaml.cs file with only a partial class declaration in it. With this dummy modification of my project, the view successfully showed up when running the application.

I removed the .xaml.cs file in the first place since until now I was pretty sure this was the recommended procedure when developing Caliburn Micro applications. For example, I believe that in most ViewModel-first CM samples there are no.xaml.cs files.

Granted, I have not verified that the View classes are included in the assemblies in non-WinRT applications, but I get the feeling that WinRT/Windows Store applications are built and compiled more aggressively. Can someone confirm or refute this, and if confirmed, does anyone know how to "reduce this aggressiveness"?

New Post: New Caliburn.Micro app in the Windows 8 App Store

$
0
0

Hey guys, just wanted to let you know that our app was published to the store. It's called MetroPass: http://apps.microsoft.com/webpdp/en-us/app/metropass/fa0bacf9-32f3-4036-8f38-327cb7c22bee.

The app is built on Caliburn.Micro, which we really enjoy using. MetroPass is aKeePass client for Windows 8/WinRT. If you've not heard of KeePass it's a pretty popular password manager application for Windows, which also has a bunch of clients for other platforms. Thanks to Caliburn there's now one for Windows 8 too. :-)

Viewing all 1760 articles
Browse latest View live


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