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

New Post: RadContextMenu with caliburn.micro

$
0
0
Hello, i use a RadContextMenu of telerik and MVVM Caliburn.Micro.

i have this xaml
<Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <myclass:LongListSelector ItemsSource="{Binding Collections}" LayoutMode="Grid" GridCellSize="215,240" SelectedItem="{Binding Path=CurrentCollection, Mode=TwoWay}"
                      cal:Message.Attach="[Event Tap] = [Action OnSelectionChangedCommand]">
                <telerikPrimitives:RadContextMenu.ContextMenu>
                    <telerikPrimitives:RadContextMenu x:Name="menu" cal:Action.TargetWithoutContext="{Binding DataContext, ElementName=LayoutRoot}">
                        <telerikPrimitives:RadContextMenuItem Content="EDIT"
                                                              cal:Message.Attach="ExecuteAction1" />
                        <telerikPrimitives:RadContextMenuItem Content="DELETE"
                                                              cal:Message.Attach="ExecuteAction1"  />
                    </telerikPrimitives:RadContextMenu>
                </telerikPrimitives:RadContextMenu.ContextMenu>
                <myclass:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        .....
                    </DataTemplate>
                </myclass:LongListSelector.ItemTemplate>
            </myclass:LongListSelector>

        </Grid>
    </Grid>
in my viewmodel c#

public void ExecuteAction1()
    { 
    }
receive this error

{System.Exception: No target found for method ExecuteAction1.
at Caliburn.Micro.ActionMessage.Invoke(Object eventArgs)
at System.Windows.Interactivity.TriggerAction.CallInvoke(Object parameter)

why?

New Post: Update Listview

$
0
0
I have a simple listview which displays data from a view model. Then I have 4 textboxes where I can enter data and click on Add button that should add the data in the collection in ViewModel. The same collection is used to display data in ListView.

Now when application loads, ListView displays the 4 records. But when I try to add a new item in collection that does not get updated in ListView.

Following is the code for ViewModel
public class AppViewModel : PropertyChangedBase
    {
        private List<LoanInfo> lstLoans;
        private string inputLoanName;
        private string inputLoanNumber;
        private string inputStatus;
        private decimal inputAmount;

        public List<LoanInfo> LoanList 
        {
            get { return lstLoans; }
            set 
            { 
                lstLoans = value;
                NotifyOfPropertyChange(() => LoanList);
            }
        }

        public string InputLoanName { 
            get
            {
                return inputLoanName;
            } 
            set 
            {
                inputLoanName = value;
                NotifyOfPropertyChange(() => InputLoanName);
            } 
        }
        public string InputLoanNumber
        {
            get
            {
                return inputLoanNumber;
            }
            set
            {
                inputLoanNumber = value;
                NotifyOfPropertyChange(() => InputLoanNumber);
            }
        }
        public string InputStatus
        {
            get
            {
                return inputStatus;
            }
            set
            {
                inputStatus = value;
                NotifyOfPropertyChange(() => InputStatus);
            }
        }
        public decimal InputAmount
        {
            get { return inputAmount; }
            set
            {
                inputAmount = value;
                NotifyOfPropertyChange(() => InputAmount);
            }
        }

        public AppViewModel()
        {
            lstLoans = new List<LoanInfo>();
            lstLoans.Add(new LoanInfo() { LoanName = "Loan1", LoanNumber="1001-1", Amount=100000, Status="Pending"});
            lstLoans.Add(new LoanInfo() { LoanName = "Loan2", LoanNumber = "1001-2", Amount = 200000, Status = "Pending" });
            lstLoans.Add(new LoanInfo() { LoanName = "Loan3", LoanNumber = "1001-3", Amount = 300000, Status = "Pending" });
            lstLoans.Add(new LoanInfo() { LoanName = "Loan4", LoanNumber = "1001-4", Amount = 400000, Status = "Pending" });
            lstLoans.Add(new LoanInfo() { LoanName = "Loan5", LoanNumber = "1001-5", Amount = 500000, Status = "Pending" });

        }

        public void AddLoan()
        {
            LoanList.Add(new LoanInfo() { LoanName = InputLoanName, LoanNumber = InputLoanNumber, Amount = InputAmount, Status = InputStatus });
            NotifyOfPropertyChange(() => LoanList);
            
        }
    }
Follwoing is the code of xaml file
<UserControl x:Class="LoanDetails.Views.AppView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d">
    <UserControl.Resources>
        <Style TargetType="TextBox">
            <Setter Property="Background" Value="Beige"></Setter>
            <Setter Property="Margin" Value="2"></Setter>
            <Setter Property="Width" Value="100"></Setter>
            <Setter Property="HorizontalAlignment" Value="Left"></Setter>
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
        </Style>
    </UserControl.Resources>
    <Grid Height="400" Width="800" ShowGridLines="True">
        <ListView Height="Auto" Width="Auto" Name="LoanList" ItemsSource="{Binding LoanList, NotifyOnSourceUpdated=True, Mode=TwoWay}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="LoanName" DisplayMemberBinding="{Binding LoanName}"></GridViewColumn>
                    <GridViewColumn Header="LoanNumber" DisplayMemberBinding="{Binding LoanNumber}"></GridViewColumn>
                    <GridViewColumn Header="Status" DisplayMemberBinding="{Binding Status}"></GridViewColumn>
                    <GridViewColumn Header="Amount" DisplayMemberBinding="{Binding Amount}"></GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        <Grid Height="100" VerticalAlignment="Bottom" ShowGridLines="True" Margin="0,0,0,40">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"></RowDefinition>
                <RowDefinition Height="25"></RowDefinition>
                <RowDefinition Height="25"></RowDefinition>
                <RowDefinition Height="25"></RowDefinition>
            </Grid.RowDefinitions>
            <Label Content="Name" Grid.Column="0" Grid.Row="0"></Label>
            <TextBox Name="InputLoanName"  Grid.Column="1" Grid.Row="0"></TextBox>
            <Label Content="Number" Grid.Column="0" Grid.Row="1"></Label>
            <TextBox Name="InputLoanNumber"  Grid.Column="1" Grid.Row="1"></TextBox>
            <Label Content="Status" Grid.Column="0" Grid.Row="2"></Label>
            <TextBox Name="InputStatus"  Grid.Column="1" Grid.Row="2"></TextBox>
            <Label Content="Amount" Grid.Column="0" Grid.Row="3"></Label>
            <TextBox Name="InputAmount"  Grid.Column="1" Grid.Row="3"></TextBox>
        </Grid>
        <Button Name="AddLoan" Content="Add" Height="30" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Right"></Button>
    </Grid>
</UserControl>
As I'm new to Caliburn.Micro, can someone plesae help?

New Post: Update Listview

$
0
0
The issue was resolved after changing
List<LoanInfo> LoanList
To
ObservableCollection<LoanInfo> LoanList

Commented 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.
Comments: Note: Caliburn.Micro moved to [GitHub](https://github.com/BlueSpire/Caliburn.Micro), so nobody will respond on issues created on CodePlex. For me this seems to be question and not an issue. Questions should be asked: - in the forum https://caliburnmicro.codeplex.com/discussions or - on StackOverflow https://stackoverflow.com/questions/tagged/caliburn.micro

Closed 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.
Comments: Project moved to Github.

Updated Wiki: Home

Updated Wiki: Documentation

$
0
0

New Post: AvalonDock and Loading Views/ViewModels in code

$
0
0
Has anyone done anything more recent in terms of creating a dock manager for RadDock and the latest builds of Caliburn.Micro? The material above is getting dated as well as being incomplete given the view side of things is not shown.

New Post: Caliburn Obfuscation

$
0
0
Make sure you have excluded your View and ViewModel namespaces from obfuscation.

The other problem I encountered was that I was using Caliburn Micro in some libraries, too, and the bootstrappers were instantiating multiple copies of my primary view model if I merged the libraries in with the main executable. I used embedding instead, and it fixed the problem.

After those two steps, it has worked fine.

New Post: How to use Cliburn.Micro in Windows 8 Store Apps ?

$
0
0
Hi Devs ,

We are developing a Windows 8 store App and need to use Caliburn.Micro lib. for it , but nuget returns with Framework not supported error. Isn't it available for Windows 8 store apps ?

Regards,

New Post: ViewLocator - locating the views for a subclassed viewmodel?

$
0
0
Very usefull, just what I needed.

thanks.

New Post: How to use Cliburn.Micro in Windows 8 Store Apps ?

New Post: Language Issue

$
0
0
I have an application for Windows Phone 8.

I supported several languages like french, spanish,english.

The problem occurs when I added the Ukranian language .(Resource File)

When I launch my App with this language . Caliburn does not work well.

OnActivate Methods do not fire.

But when I back to english or spanish Caliburn Works well.

can anyone help me to solve this problem?.

Thank you.

New Post: [WP8] Panorama control does not work with data-binding

New Post: [WPF] Handling unhandled exceptions with async/await

$
0
0
Hi,

I'm trying to take care of unhandled exceptions with async/await on a wpf project. The main purpose is to keep track of the exceptions that will be swallowed.
So far, I found this approach who uses SynchronizationContext but it's based on a Win8 application.

So I tried to "register" my SynchronizationContext in my App.xaml.cs but the SynchronizationContext.current is always null :
 public partial class App : Application
    {
        public App()
            : base()
        {
            AsyncSynchronizationContext.Register();
        }
    }
 public class AsyncSynchronizationContext : SynchronizationContext
    {
        public static AsyncSynchronizationContext Register()
        {
            
            var syncContext = Current;
            if (syncContext == null)
                throw new InvalidOperationException("Ensure a synchronization context exists before calling this method.");

            var customSynchronizationContext = syncContext as AsyncSynchronizationContext;

            if (customSynchronizationContext == null)
            {
                customSynchronizationContext = new AsyncSynchronizationContext(syncContext);
                SetSynchronizationContext(customSynchronizationContext);
            }

            return customSynchronizationContext;
        }
...
}
Should I register somewhere else in the Bootstrapper ?
Maybe there's other way to manage those exceptions with async/await.

Any suggestions?

Thanks,
nico

New Post: [WPF] Handling unhandled exceptions with async/await

New Post: Language Issue

New Post: Caliburn Obfuscation

$
0
0
Thank you very much.
I tried to do exactly what you said but no luck.
After trying to build a SmartAssembly project my application keeps crashing.

From where do I need to exclude the View and ViewModel namespaces? From SmartAssembly or from my code?
If you can help me again that would be great.

Thanks again.

New Post: [WPF] Handling unhandled exceptions with async/await

$
0
0
Thanks for the link but I ended with the same solution (SynchronizationContext).

I edited my first post to be a bit more specific as the real problem here is with Caliburn.

New Post: Use Microphone in ViewModel, Error NullReferenceException

$
0
0
i use a pattern MVVM Caliburn Micro (Windows phone 8) and in my ViewModel i have this code

private Microphone microphone;
private byte[] buffer;
private MemoryStream stream;

public MainViewModel()
{

    microphone = Microphone.Default;
    stream = new MemoryStream();

    DispatcherTimer dt = new DispatcherTimer();
    dt.Interval = TimeSpan.FromMilliseconds(50);
    dt.Tick += delegate
    {
        try
        {
            FrameworkDispatcher.Update();
        }
        catch { }
    };
    dt.Start();
    microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);


}

 void microphone_BufferReady(object sender, EventArgs e)
    {
    }
on this microphone.BufferReady += new EventHandler(microphone_BufferReady);

receive error => System.NullReferenceException: Object reference not set to an instance of an object

WHY?
Viewing all 1760 articles
Browse latest View live


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