Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:44:47+00:00 2026-06-01T12:44:47+00:00

I need to write a small application to read a configuration file and generate

  • 0

I need to write a small application to read a configuration file and generate some report with it. I was hoping to finally use MVVM but it’s quite tricky to get started. Oh, I’m using Caliburn.Micro framework.

So this is what I have, a shell (primary view that hosts other views) that has a ribbon with 3 buttons on it:

1) Open file
2) Show settings
3) Show results

And two other views, SettingsView and ResultsView with buttons to generate and delete a report.

So I guess the view structure would be like this:

ShellView
   Ribbon
      OpenFileButton
      SettingsButton
      ResultsButton
   ContentControl (hosts SettingsView and ResultsView)

SettingsView
    CalculateResultsButton

ResultsView
    CancelResultsButton

The tricky part is this:

1. "Show settings" button is disabled until a file is opened (via Open file). 
2. "Show results" button is disabled until a report is calculated (via a 
    method in SettingsViewModel).
3. If a report is calculated, the CalculateResultsButton is disabled and
   CancelResultsButton is enabled and vice versa.

Please advise how could I achieve this ? I’ve no ideas what strategy should I go for. My non-MVVM-thinking-brain says that I should create a status variable and then somehow bind those buttons to that variable, but I guess that wont work in a MVVM world, right ? Any code example would be very very very appreciated!

Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:44:49+00:00Added an answer on June 1, 2026 at 12:44 pm

    Since you’re using CM you won’t need any code-behind. You can delete the .xaml.cs files if you want.

    This is a pretty basic example but it should give you an idea on how to control the state of the buttons. In this example, Open will be enabled and the other two are disabled. If you click on Open, Settings is enabled. The same happens with Results once Settings is clicked.

    If you need a way to do global state the same concept can be applied by injecting a singleton, SharedViewModel, into the ViewModels and the CanXXX methods can check values in SharedViewModel. This is a SL demo of different things but one is injecting a singleton to share data, the same idea applies in wpf.

    ShellView:

    <Window x:Class="CMWPFGuardSample.ShellView"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
        <Grid Background="White">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0"
                        Orientation="Horizontal">
                <Button x:Name="Open"
                        Content="Open" />
                <Button x:Name="Settings"
                        Content="Settings" />
                <Button x:Name="Results"
                        Content="Results" />
            </StackPanel>
        </Grid>
    
    </Window>
    

    ShellViewModel:

     [Export(typeof (IShell))]
        public class ShellViewModel : PropertyChangedBase, IShell
        {
            private bool _isOpen;
            public bool IsOpen
            {
                get { return _isOpen; }
                set
                {
                    _isOpen = value;
                    NotifyOfPropertyChange(() => IsOpen);
                    NotifyOfPropertyChange(() => CanSettings);
                }
            }
    
            private bool _isSettings;
            public bool IsSettings
            {
                get { return _isSettings; }
                set
                {
                    _isSettings = value;
                    NotifyOfPropertyChange(() => IsSettings);
                    NotifyOfPropertyChange(() => CanResults);
                }
            }
    
            public bool IsResults { get; set; }
    
            public void Open()
            {
                IsOpen = true;
            }
    
            public bool CanSettings
            {
                get { return IsOpen; }
            }
    
            public void Settings()
            {
                IsSettings = true;
            }
    
            public bool CanResults
            {
                get { return IsSettings; }
            }
    
            public void Results()
            {
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write small a log analyzer application to process some log files
As the title says, I need to write a small program to read data
I'm working on an application in C# and need to read and write from
Please forgive my attempts at necromancy, but I actually need to write some code
I have an application where the user select configuration, I need to write to
I am trying to write a small interactive game-like application, where I need to
I used SQLite3 to implement small application to read from or write to a
In my project I need to write small WYSIWYG editor (just let users make
I need to write a small program that can detect that it has been
I need to write a small console app (patch) that turns off the print

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.