Click here to Skip to main content
15,881,836 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: iDB2Connection Connection slow Pin
byka29-Jul-14 6:55
byka29-Jul-14 6:55 
GeneralRe: iDB2Connection Connection slow Pin
Eddy Vluggen29-Jul-14 12:10
professionalEddy Vluggen29-Jul-14 12:10 
GeneralRe: iDB2Connection Connection slow Pin
Bernhard Hiller29-Jul-14 20:26
Bernhard Hiller29-Jul-14 20:26 
AnswerRe: iDB2Connection Connection slow Pin
Pete O'Hanlon30-Jul-14 3:47
mvePete O'Hanlon30-Jul-14 3:47 
Question.NET FILE. Pin
Member 1096807828-Jul-14 7:12
Member 1096807828-Jul-14 7:12 
AnswerRe: .NET FILE. Pin
ZurdoDev28-Jul-14 7:49
professionalZurdoDev28-Jul-14 7:49 
GeneralRe: .NET FILE. Pin
Akhil Mittal6-Aug-14 20:17
professionalAkhil Mittal6-Aug-14 20:17 
QuestionWPF Datagrid from XML Pin
Member 1007423926-Jul-14 22:19
Member 1007423926-Jul-14 22:19 
I am new to WPF and the MVVM structure but I have create a simple? project which works fine.

DataModel

class MotionModel : INotifyPropertyChanged
    {
       
        public event PropertyChangedEventHandler PropertyChanged;
        public event PropertyChangingEventHandler PropertyChanging;

        
        private string m_TabletID;
        public string TabletID
        {
            get { return m_TabletID; }
            set
            {
                if (PropertyChanging != null)
                    PropertyChanging(this, new PropertyChangingEventArgs("TabletID"));
                m_TabletID = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("TabletID"));
            }
        }

        
        private string m_Instance;
        public string Instance
        {
            get { return m_Instance; }
            set
            {
                if (PropertyChanging != null)
                    PropertyChanging(this, new PropertyChangingEventArgs("Instance"));
                m_Instance = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("Instance"));
            }
        }

        
        private string m_Database;
        public string Database
        {
            get { return m_Database; }
            set
            {
                if (PropertyChanging != null)
                    PropertyChanging(this, new PropertyChangingEventArgs("Database"));
                m_Database = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("Database"));
            }
        }



        public class DelegateCommand : ICommand
        {

            Predicate<object> canExecute;
            Action<object> execute;

            public DelegateCommand(Predicate<object> _canexecute, Action<object> _execute)
                : this()
            {
                canExecute = _canexecute;
                execute = _execute;
            }

            public DelegateCommand()
            {

            }

            public bool CanExecute(object parameter)
            {
                return canExecute == null ? true : canExecute(parameter);
            }

            public event EventHandler CanExecuteChanged;

            public void Execute(object parameter)
            {
                execute(parameter);
            }
        }


ViewModel
class MotionViewModel : BaseModel
   {
       ObservableCollection<MotionModel> motiontablets;
       ICommand _command;
       public MotionViewModel()
       {
           Title = "Tablets";
           TabletInfo = new ObservableCollection<MotionModel>();

           TabletInfo.Add(new MotionModel { TabletID = "RHL005771", Instance = @"\SQLEXPRESS", Database = "ACQ_RH_EXP_TABLET"});
           TabletInfo.Add(new MotionModel { TabletID = "RHL005772", Instance = @"\SQLEXPRESS", Database = "ACQ_RH_EXP_TABLET" });
           TabletInfo.Add(new MotionModel { TabletID = "RHL005773", Instance = @"\SQLEXPRESS", Database = "ACQ_RH_EXP_TABLET" });
           TabletInfo.Add(new MotionModel { TabletID = "RHL005774", Instance = @"\SQLEXPRESS", Database = "ACQ_RH_EXP_TABLET" });
           TabletInfo.Add(new MotionModel { TabletID = "RHL005775", Instance = @"\SQLEXPRESS", Database = "ACQ_RH_EXP_TABLET" });
           TabletInfo.Add(new MotionModel { TabletID = "RHL005776", Instance = @"\SQLEXPRESS", Database = "ACQ_RH_EXP_TABLET" });
       }
       public ObservableCollection<MotionModel> TabletInfo
       {
           get
           {
               return motiontablets;
           }
           set
           {
               motiontablets = value;
               OnPropertyChanged("TabletInfo");
           }
       }

       public string Title { get; set; }

       public ICommand RemoveCommand
       {
           get
           {
               if (_command == null)
               {
                   _command = new RHG_MVVM.Model.MotionModel.DelegateCommand(CanExecute, Execute);
               }
               return _command;
           }
       }

       private void Execute(object parameter)
       {
           int index = TabletInfo.IndexOf(parameter as MotionModel);
           if (index > -1 && index < TabletInfo.Count)
           {
               TabletInfo.RemoveAt(index);
           }
       }

       private bool CanExecute(object parameter)
       {
           return true;
       }


My XAML is
XML
<Window x:Class="RHG_MVVM.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:View="clr-namespace:RHG_MVVM.View"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <View:Tablets/>
    </Grid>
</Window>


My question is how do I get me TabletINfo to load and write back to a XML file as two way binding???

Thanks
QuestionDirectinput error Pin
mr.kage26-Jul-14 4:27
mr.kage26-Jul-14 4:27 
AnswerRe: Directinput error Pin
Dave Kreskowiak26-Jul-14 10:10
mveDave Kreskowiak26-Jul-14 10:10 
AnswerRe: Directinput error Pin
ZurdoDev28-Jul-14 8:01
professionalZurdoDev28-Jul-14 8:01 
AnswerRe: Directinput error Pin
Gerry Schmitz28-Jul-14 10:13
mveGerry Schmitz28-Jul-14 10:13 
QuestionExchange 2010 - Out Of Office Rule Pin Pin
Serrurier Toulon19-Jul-14 8:44
Serrurier Toulon19-Jul-14 8:44 
AnswerRe: Exchange 2010 - Out Of Office Rule Pin Pin
Eddy Vluggen21-Jul-14 3:17
professionalEddy Vluggen21-Jul-14 3:17 
QuestionFatal error encountered during command execution asp.net C# Pin
ven75319-Jul-14 4:38
ven75319-Jul-14 4:38 
AnswerRe: Fatal error encountered during command execution asp.net C# Pin
Eddy Vluggen21-Jul-14 3:15
professionalEddy Vluggen21-Jul-14 3:15 
QuestionThe Operation Has time out problme while sending SMS Pin
hareshdgr810-Jul-14 21:01
hareshdgr810-Jul-14 21:01 
AnswerRe: The Operation Has time out problme while sending SMS Pin
Dave Kreskowiak11-Jul-14 1:39
mveDave Kreskowiak11-Jul-14 1:39 
SuggestionRe: The Operation Has time out problme while sending SMS Pin
jinzai17-Jul-14 0:57
jinzai17-Jul-14 0:57 
AnswerRe: The Operation Has time out problme while sending SMS Pin
jinzai17-Jul-14 1:09
jinzai17-Jul-14 1:09 
Questionis it possible to sample my screen? Pin
neodeaths7-Jul-14 13:24
neodeaths7-Jul-14 13:24 
AnswerRe: is it possible to sample my screen? Pin
Dave Kreskowiak7-Jul-14 15:25
mveDave Kreskowiak7-Jul-14 15:25 
GeneralRe: is it possible to sample my screen? Pin
neodeaths7-Jul-14 17:12
neodeaths7-Jul-14 17:12 
GeneralRe: is it possible to sample my screen? Pin
Dave Kreskowiak7-Jul-14 17:45
mveDave Kreskowiak7-Jul-14 17:45 
AnswerRe: is it possible to sample my screen? Pin
PIEBALDconsult7-Jul-14 15:42
mvePIEBALDconsult7-Jul-14 15:42 

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.