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

New Post: updating ToggleButton IsEnabled property throws exception

$
0
0
thanks for the reply.

yes I did realized that and desiged the test according to to your instructions in the first place.

however, the CanSayHello value had no effect for the ToggleButton IsEnabled state

Creating the Binding fixed that and the ToggleButton started to respond to the guard state

however, when i added a stack pannel to the ToggleButton, the exception described above was started a appear

New Post: Roadmap over Caliburn Micro

$
0
0
I'm intended to use Caliburn Micro 2.0.0 in my application, as the app is based on Win 8.1. The current 1.5.2 isn't working out. I cannot use alpha releases as my client would refuse to. So, can you publish a roadmap for Micro? TIA.

New Post: updating ToggleButton IsEnabled property throws exception

$
0
0
one thing I didn't do was name the nested stackpanel but unless you had another property with the "sp" name that was doing something weird I don't know. It should work with the guard, at least it did on my end and the togglebutton became active.

New Post: Convention on SelectedCellsChanged with RadGridView

$
0
0
Hello,
I was using the following convention for the SelectionChanged on RadGridView
            ConventionManager.AddElementConvention<DataControl>(DataControl.ItemsSourceProperty, "SelectedDataItem",
             "SelectionChanged")
                    .ApplyBinding = (viewModelType, path, property, element, convention) =>
                    {
                        if (!ConventionManager.SetBindingWithoutBindingOrValueOverwrite(viewModelType,
                         path,
                         property,
                         element,
                         convention,
                         DataControl.ItemsSourceProperty))
                            return false;

                        if (ConventionManager.HasBinding(element, DataControl.SelectedItemProperty)) return true;
                        var index = path.LastIndexOf('.');
                        index = index == -1 ? 0 : index + 1;
                        var baseName = path.Substring(index);
                        foreach (var selectionPath in
                                from potentialName in ConventionManager.DerivePotentialSelectionNames(baseName)
                                where
                                        viewModelType.GetProperty(potentialName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) !=
                                        null
                                select path.Replace(baseName, potentialName))
                        {
                            var binding = new Binding(selectionPath) { Mode = BindingMode.TwoWay };
                            BindingOperations.SetBinding(element, DataControl.SelectedItemProperty, binding);
                        }
                        return true;
                    };
and it was working till I had to change the Selection mode from FullRow to "Cell", in that wat the selecteditem is not fired but the event fired is SelectedCellsChanged.

I'm not able to write a convention for updating the selecteditem...anyone can help me?
Thanks

Updated Wiki: Home

$
0
0

Caliburn.Micro is a small, yet powerful framework, designed for building applications across all XAML platforms. With strong support for MVVM and other proven UI patterns, Caliburn.Micro will enable you to build your solution quickly, without the need to sacrifice code quality or testability.

This project has moved to github: https://github.com/BlueSpire/Caliburn.Micro

This community project is sponsored by Xceed, makers of Xceed DataGrid for WPF, the enterprise datagrid that provides a rich, fluid, and high performance user experience. 50% off any Xceed product with coupon code G00B8T. Xceed also offers Extended Silverlight Toolkit and Extended WPF Toolkit here on Codeplex.

The Caliburn.Micro team uses ReSharper by JetBrains.

If you like what you find here, please consider donating.

Updated Wiki: Home

Updated Wiki: Home

Updated Wiki: Home


Updated Wiki: Documentation

$
0
0

Updated Wiki: Home

Updated Wiki: Documentation

$
0
0

Created Unassigned: CameraCaptureTask with Caliburn Micro [359]

Commented Unassigned: CameraCaptureTask with Caliburn Micro [359]

$
0
0
How to?
thank you
Comments: questions should go to StackOverflow (https://stackoverflow.com/questions/tagged/caliburn.micro).

New Post: Multiple views per viewmodel in a ListView

$
0
0
I am trying to use the View.Context tag in my caliburn app to support multiple views on the same viewmodel.

I have a Root View containing the following code
<ListView x:Name="Elements">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ContentControl cal:Bind.Model="{Binding}"  cal:View.Context="Tree"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
and my root viewmodel contains
public class RootViewModel
{
       public ObservableCollection<DocumentViewModel> Elements 
}
I have defined 2 views for my document, Preview and Tree.
named the files :
...\Views\Document.Tree.xaml ->x:Class=[namespace].Views.Document.Tree
and
...\Views\Document.Preview.xaml ->x:Class=[namespace].Views.Document.Preview

result:
Caliburn can't find view for the document view model, did I get the naming convention wrong somehow?
also I intercept the LocateForModel func and added some logging, I expected the third param (of type object) to be the given context but it's always null.
I'm probably missing something obvious here ...

New Post: ListBox.SelectedItems convention

$
0
0
Just as a note to anyone who might run into this issue. NotifyCollectionChangedAction.Reset is not a Clear so the following piece in UpdateSelection.ReceiveWeakEvent`:
if (args.Action == NotifyCollectionChangedAction.Reset)
{
    list.Clear();
}
should be changed to:
if (args.Action == NotifyCollectionChangedAction.Reset)
{
    list.Clear();
    if (sender != null)
        foreach (var item in (IList)sender)
            list.Add(item);
}
This is only really noticeable when doing an AddRange or RemoveRange in BindableCollection or any other observable collection that uses Reset for changes other than Clear.
The added items are not available on args.NewItems so that's not an option in this case.

edit: added null check even though it's arguable that an exception should be throw if sender is null, take your pick.

New Post: Multiple views per viewmodel in a ListView

$
0
0
what is the name of the root view?

New Post: Multiple views per viewmodel in a ListView

$
0
0
My root view is called "RootView" and gets resolved properly.

New Post: Multiple views per viewmodel in a ListView

$
0
0
try putting Tree.xaml and Preview.xaml into a folder called Root under Views

New Post: Cannot find views when control hosted in WinForms application

$
0
0
Hi,

I have a WPF application which works correctly when run as the startup project but which fails to locate the views for my viewmodels when it is hosted in a winforms application. The views and viewmodels are located in the same project under the namespaces:
RopeAccess.WPF.Manifest.Views and RopeAccess.WPF.Manifest.ViewModels.

I have tried overriding the SelectAssemblies method with:
        protected override IEnumerable<Assembly> SelectAssemblies()
        {
            yield return Assembly.GetExecutingAssembly();
            yield return typeof (ManifestBootstrapper).Assembly;
            yield break;
        }
and the constructor for my bootstrapper is as follows:
        public ManifestBootstrapper(ElementHost host)
            : base(false)
        {
            SetupIoC();
            var shellViewModel = _kernel.Get<ManifestShellViewModel>();
            var shellView = _kernel.Get<ManifestShellView>();
            ViewModelBinder.Bind(shellViewModel, shellView, null);
            host.Child = shellView;
        }
This correctly loads the Shell into the ElementsHost but all child views inside the shell display as "Could not find view for RopeAccess.WPF.Manifest.Viewmodels.X"

I have also tried adjusting the namespace mappings for the ViewLocator such as:
ViewLocator.AddNamespaceMapping("RopeAccess.WPF.Manifest.ViewModels", "RopeAccess.WPF.Manifest.Views");
Is there something I am missing to allow Caliburn Micro to locate the views?

New Post: DependencyInjection on Opening a Window

$
0
0
Hey guys!

So, I use StructureMap's dependency injection with Caliburn.Micro. All of my ViewModels incorporate DI in the constructor arguments. I'm now at the point where I need to open, close, and hide windows (Probably by passing along IAppWindowManager (which inherits from IWindowManager).

Unfortunately, what I'm stuck at is resolving an instantiation of the view and view model with dependency injection using the container defined in my bootstrapper. So far, this is what I have.
    public class AppWindowManager
        : WindowManager, IAppWindowManager
    {
        private readonly IDictionary<Type, Window> _windows
            = new Dictionary<Type, Window>();

        public void Open<T>()
        {
            var window 
                = _windows.Any(d => d.Key 
                    == typeof(T));
            if (window)
            {
                _windows.SingleOrDefault(d => d.Key 
                    == typeof(T)).Value.Show();
                return;
            }

            // Create window
            //_windows.Add(typeof(T),
            //    CreateWindow(T, false, null, null)); <-- Erk?
        }

        public void Close<T>()
        {
            var window
                = _windows.Any(d => d.Key
                    == typeof(T));
            if (!window)
                throw new ArgumentNullException();

            // Delete window
            //_windows.SingleOrDefault(d => d.Key
            //        == typeof(T)).Value.Close(); <-- Also erk!
            _windows.Remove(typeof(T));
        }

        public override void ShowWindow(object rootModel,
            object context = null, IDictionary<string, object> settings = null) {
            var navigationWindow = (NavigationWindow)null;
            if (Application.Current != null && Application.Current.MainWindow != null)
                navigationWindow = Application.Current.MainWindow as NavigationWindow;
            if (navigationWindow != null) {
                var page = CreatePage(rootModel, context, settings);
                navigationWindow.Navigate(page);
            } else
            {
                if (rootModel.GetType() == typeof(TrayIconViewModel))
                    CreateWindow(rootModel, false, context, settings);
                else
                    CreateWindow(rootModel, false, context, settings).Show();
            }
        }
    }
And
public class AppBootstrapper
        : BootstrapperBase
    {
        private IContainer _container;

        public AppBootstrapper()
        {
            Start();
        }

        protected override void Configure()
        {
            _container 
                = IoC.Initialize();
        }

        protected override object GetInstance(Type serviceType, string key)
        {
            object service;
            if (!serviceType.IsAbstract 
                && !serviceType.IsInterface 
                && serviceType.IsClass) {
                // Concrete type resolution
                service = _container.GetInstance(serviceType);
            } else {
                // Other type resolution.
                service = _container.TryGetInstance(serviceType) ?? base.GetInstance(serviceType, key);
            }
            return service;
        }

        protected override IEnumerable<object> GetAllInstances(Type serviceType) {
            return _container.GetAllInstances(serviceType).Cast<object>();
        }

        protected override void OnStartup(object sender, StartupEventArgs e) {
            DisplayRootViewFor<TrayIconViewModel>();
        }
    }
One possible resolution I can think of is passing the container into the IAppWindowManager, but I think that has some code smell. I'm also not sure if that would work, given the class is hooked up while the container is being made. Am I perhaps using the wrong class to control and instantiate windows? I couldn't find much documentation on the WindowConductor, and I'm not sure if that's better suited to what I'm trying to do.

Thanks for the help!
Viewing all 1760 articles
Browse latest View live


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