Click here to Skip to main content
15,888,401 members
Home / Discussions / C#
   

C#

 
QuestionEWS Managed API : "The SMTP address has no mailbox associated with it." Pin
Kuthuparakkal28-Jun-16 2:16
Kuthuparakkal28-Jun-16 2:16 
AnswerRe: EWS Managed API : "The SMTP address has no mailbox associated with it." Pin
OriginalGriff28-Jun-16 2:25
mveOriginalGriff28-Jun-16 2:25 
QuestionFloating window implementation using c# Pin
srikrishnathanthri27-Jun-16 19:49
srikrishnathanthri27-Jun-16 19:49 
QuestionNeed Help with Assignment board logic. Pin
Aspylacide27-Jun-16 15:38
Aspylacide27-Jun-16 15:38 
AnswerRe: Need Help with Assignment board logic. Pin
Gerry Schmitz27-Jun-16 19:52
mveGerry Schmitz27-Jun-16 19:52 
AnswerRe: Need Help with Assignment board logic. Pin
Nathan Minier28-Jun-16 1:49
professionalNathan Minier28-Jun-16 1:49 
AnswerRe: Need Help with Assignment board logic. Pin
BillWoodruff28-Jun-16 4:39
professionalBillWoodruff28-Jun-16 4:39 
GeneralRe: Need Help with Assignment board logic. Pin
Aspylacide28-Jun-16 13:34
Aspylacide28-Jun-16 13:34 
AnswerRe: Need Help with Assignment board logic. Pin
Aspylacide28-Jun-16 14:02
Aspylacide28-Jun-16 14:02 
SuggestionRe: Need Help with Assignment board logic. Pin
Aspylacide29-Jun-16 12:25
Aspylacide29-Jun-16 12:25 
Questionc# project Pin
Member 1260671027-Jun-16 11:21
Member 1260671027-Jun-16 11:21 
AnswerRe: c# project Pin
OriginalGriff27-Jun-16 19:44
mveOriginalGriff27-Jun-16 19:44 
QuestionCreate update for your program in C# Pin
Bilal PC27-Jun-16 9:32
Bilal PC27-Jun-16 9:32 
AnswerRe: Create update for your program in C# Pin
Dave Kreskowiak27-Jun-16 10:00
mveDave Kreskowiak27-Jun-16 10:00 
GeneralThis question is removed Pin
lokeshnj27-Jun-16 4:32
lokeshnj27-Jun-16 4:32 
AnswerRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Eddy Vluggen27-Jun-16 7:29
professionalEddy Vluggen27-Jun-16 7:29 
GeneralRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Jim_Snyder30-Jun-16 4:18
professionalJim_Snyder30-Jun-16 4:18 
GeneralRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Eddy Vluggen30-Jun-16 4:21
professionalEddy Vluggen30-Jun-16 4:21 
GeneralRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Jim_Snyder30-Jun-16 4:27
professionalJim_Snyder30-Jun-16 4:27 
GeneralRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Eddy Vluggen30-Jun-16 7:58
professionalEddy Vluggen30-Jun-16 7:58 
GeneralRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Jim_Snyder1-Jul-16 3:13
professionalJim_Snyder1-Jul-16 3:13 
GeneralRe: I have requirement to compare two list or any container which is feasible for the requirement in C#.net Pin
Jim_Snyder30-Jun-16 4:33
professionalJim_Snyder30-Jun-16 4:33 
Questionhow to fire up the message receive handler on runtime? Pin
Member 1255232425-Jun-16 23:46
Member 1255232425-Jun-16 23:46 
AnswerRe: how to fire up the message receive handler on runtime? Pin
OriginalGriff26-Jun-16 1:13
mveOriginalGriff26-Jun-16 1:13 
QuestionCommand Binding Pin
Member 1245711024-Jun-16 3:46
Member 1245711024-Jun-16 3:46 
I have followed Josh Smith's article "Patterns - WPF Apps with the Model-View-ViewModel Design Pattern" , and examples in two books. But I still don't see what is going on in my attempt to bind a Command to a ViewModel.
In my XAML I have:
HTML
<Window x:Class="Samples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:Samples.ViewModel"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interctivity"
        Title="MainWindow" Style="{StaticResource styWindow}">

    <Window.DataContext>
        <vm:LabTechViewModel />
    </Window.DataContext>

    <Window.Resources>
        
        <DataTemplate x:Key="techData">
            <Border Margin="2"
                BorderThickness="2"
                CornerRadius="4"
                BorderBrush="SteelBlue" 
                    HorizontalAlignment="Stretch">
                <Grid ShowGridLines="False" HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Text="{Binding TechID}">
                    </TextBlock>
                    <TextBlock Grid.Row="1" Text="{Binding TechName}" FontWeight="Bold">
                    </TextBlock>
                </Grid>
            </Border>
        </DataTemplate>
        
        <DataTemplate x:Key="progBar">
            <Border BorderThickness="2"
                    BorderBrush="Blue"
                    CornerRadius="4"
                    HorizontalAlignment="Stretch">
                <Grid>
                <ProgressBar HorizontalAlignment="Stretch"
                             VerticalAlignment="Stretch"
                             Minimum="{Binding Minimum}"
                             Maximum="{Binding Maximum}"
                             Value="{Binding ProgressValue}"/>
                <Button x:Name="progButton"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Command="{Binding ProgressCommand}"
                    Content="{Binding ProgressButtonContent, FallbackValue='Bite Me'}"
                    Background="Transparent" />
                </Grid>             
            </Border>
        </DataTemplate>
        
    </Window.Resources>

    <Grid ShowGridLines="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel>

            <ComboBox x:Name="lstOperators"
                    HorizontalAlignment="Stretch"
                    HorizontalContentAlignment="Stretch"
                    ItemsSource="{Binding LabTechs}"
                    ItemTemplate="{StaticResource techData}"
                    SelectedItem="{Binding LabTechSelected}"
                    SelectedIndex="0"
                    >
            </ComboBox>
            
            <ContentControl ContentTemplate="{StaticResource progBar}"
                            >
                
            </ContentControl>


        </StackPanel>
    </Grid>
</Window>


An I have this in my ViewModel. Some of the ViewModel has been left out for brevity.
C#
//This is the constructor
        public LabTechViewModel()
        {
            _techList = DataAccess.GetAllLabTechs();
            _progressCommand = new RelayCommand(param => this.OnProgressClicked());
        }

        private RelayCommand _progressCommand;
        public ICommand ProgressCommand
        {
            get
            {
                if (_progressCommand == null)
                    _progressCommand = new RelayCommand(param => this.OnProgressClicked());

                return _progressCommand;
            }
        }

        void OnProgressClicked()
        {
            if (_progButtonContent == "Stopped, Click to Start")
            {
                //Start the Comm scan 
                _progButtonContent = "Scanning, click to stop";
                RaisePropertyChanged("ProgressButtonContent");
                RaisePropertyChanged("ProgressMaximum");
                RaisePropertyChanged("ProgerssMinimum");
            }
        }


And I have this RelayCommand Class that was repeated in the book examples. I am including the entire class here.

C#
class RelayCommand : ICommand
{
    readonly Action<object> _execute;
    readonly Predicate<object> _canExecute;

    public RelayCommand(Action<object> execute, Predicate<object> canExecute)
    {
        if (execute == null) throw new ArgumentNullException("execute");

        _execute = execute;
        _canExecute = canExecute;
    }

    public RelayCommand(Action<object> execute) : this(execute, null) { }

    public bool CanExecute(object parameters)
    {
        return _canExecute == null ? true : _canExecute(parameters);
    }

    public event EventHandler CanExecuteChanged
    {
        add { CommandManager.RequerySuggested += value; }
        remove { CommandManager.RequerySuggested -= value; }
    }

    public void Execute(object parameters)
    {
        _execute(parameters);
    }
}


It appears that I am missing the magic link. I have a break point set at the ICommand ProgressCommand property and it never gets hit.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.