Click here to Skip to main content
15,916,378 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
SledgeHammer0121-Apr-11 9:33
SledgeHammer0121-Apr-11 9:33 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
Ian Shlasko21-Apr-11 10:00
Ian Shlasko21-Apr-11 10:00 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
SledgeHammer0121-Apr-11 11:29
SledgeHammer0121-Apr-11 11:29 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
Ian Shlasko21-Apr-11 15:27
Ian Shlasko21-Apr-11 15:27 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
SledgeHammer0121-Apr-11 17:06
SledgeHammer0121-Apr-11 17:06 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
Ian Shlasko21-Apr-11 17:22
Ian Shlasko21-Apr-11 17:22 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
Pete O'Hanlon22-Apr-11 9:25
mvePete O'Hanlon22-Apr-11 9:25 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
SledgeHammer0122-Apr-11 9:52
SledgeHammer0122-Apr-11 9:52 
GeneralRe: Any trick for *REUSABLE* "Application" class? Pin
Pete O'Hanlon22-Apr-11 9:56
mvePete O'Hanlon22-Apr-11 9:56 
QuestionHmm ...MVVM ... Is this Bad? I can't decide Pin
Jammer21-Apr-11 4:26
Jammer21-Apr-11 4:26 
AnswerRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
BobJanova21-Apr-11 4:51
BobJanova21-Apr-11 4:51 
GeneralRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
Jammer21-Apr-11 5:02
Jammer21-Apr-11 5:02 
GeneralRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
Pete O'Hanlon21-Apr-11 10:04
mvePete O'Hanlon21-Apr-11 10:04 
GeneralRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
Jammer22-Apr-11 2:57
Jammer22-Apr-11 2:57 
GeneralRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
Pete O'Hanlon22-Apr-11 9:12
mvePete O'Hanlon22-Apr-11 9:12 
GeneralRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
Jammer22-Apr-11 10:38
Jammer22-Apr-11 10:38 
GeneralRe: Hmm ...MVVM ... Is this Bad? I can't decide Pin
Jammer25-Apr-11 22:38
Jammer25-Apr-11 22:38 
AnswerRe: Hmm ...MVVM ... Is this Bad? I can't decide [modified] Pin
BubingaMan28-Apr-11 1:59
BubingaMan28-Apr-11 1:59 
QuestionHow to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Rocky2320-Apr-11 2:24
Rocky2320-Apr-11 2:24 
AnswerRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Tarun.K.S20-Apr-11 3:05
Tarun.K.S20-Apr-11 3:05 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls [modified] Pin
Rocky2320-Apr-11 3:28
Rocky2320-Apr-11 3:28 
No my previous code is fine...

it is giving problem only when i used to display the data in a textboxes which is selected from listbox,
it will display data in the particular UI COntrol, but if i clicked on delete here by selecting a listbox data, it is giving exception,

Exception is Null Reference is Unhandled(Object reference not set to an instance of an object).

i dont know why it is giving exception like null refence when clicked on delete...
So any help in fixing this...

when it come back to btndeletedirective, it is taking the value of i as -1(i=-1) and its reading the i value as 0 in textchanged event if i select the data which is in 3rd row in a listbox..

private void txtDirectiveName_TextChanged(object sender, TextChangedEventArgs e)
        {
            string strDirective = txtDirectiveName.Text.Trim();
            string strDescription = txtDirectiveDescription.Text.Trim();
            int i = lbDirectiveList.SelectedIndex;
            if (!string.IsNullOrEmpty(strDirective))
            {
                    listdata.Insert(i, new Directive { DirectiveName = strDirective, DirectiveDescription = strDescription });
                    lbDirectiveList.SelectedIndex = i;
                    listdata.RemoveAt(i + 1);                
            }
        }

        private void txtDirectiveDescription_TextChanged(object sender, TextChangedEventArgs e)
        {
            string strDirective = txtDirectiveName.Text.Trim();
            string strDescription = txtDirectiveDescription.Text.Trim();
            int i = lbDirectiveList.SelectedIndex;
            if (!string.IsNullOrEmpty(strDescription))
            {
                    listdata.Insert(i, new Directive { DirectiveName = strDirective, DirectiveDescription = strDescription });
                    lbDirectiveList.SelectedIndex = i;
                    listdata.RemoveAt(i + 1);
            }
        }

        private void lbDirectiveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            gDirectiveDetails.IsEnabled = true;
            int i = lbDirectiveList.SelectedIndex;
            if (i < listdata.Count && i >= 0)
                btnDeleteDirective.IsEnabled = true;
            Directive lstdata = (Directive)lbDirectiveList.SelectedItem;
            txtDirectiveName.Text = lstdata.DirectiveName.ToString();
            txtDirectiveDescription.Text = lstdata.DirectiveDescription.ToString();

        }

        private void BtnDeleteDirectiveClicked(object sender, RoutedEventArgs e)
        {
            int i = lbDirectiveList.SelectedIndex;
            if (i < listdata.Count && i >= 0)
            {
                listdata.Remove((Directive)lbDirectiveList.SelectedItem);
            }
            btnDeleteDirective.IsEnabled = false;
            ResetControls();
        }


modified on Wednesday, April 20, 2011 9:43 AM

GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Tarun.K.S20-Apr-11 3:59
Tarun.K.S20-Apr-11 3:59 
AnswerRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Ian Shlasko20-Apr-11 3:57
Ian Shlasko20-Apr-11 3:57 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Tarun.K.S20-Apr-11 4:09
Tarun.K.S20-Apr-11 4:09 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Ian Shlasko20-Apr-11 4:12
Ian Shlasko20-Apr-11 4:12 

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.