Click here to Skip to main content
15,886,799 members
Home / Discussions / WPF
   

WPF

 
QuestionMake two listboxes have the same width Pin
Jean-Louis Leroy6-May-11 2:43
Jean-Louis Leroy6-May-11 2:43 
AnswerRe: Make two listboxes have the same width Pin
Ian Shlasko6-May-11 3:09
Ian Shlasko6-May-11 3:09 
GeneralRe: Make two listboxes have the same width Pin
Jean-Louis Leroy6-May-11 3:18
Jean-Louis Leroy6-May-11 3:18 
GeneralRe: Make two listboxes have the same width Pin
Ian Shlasko6-May-11 3:31
Ian Shlasko6-May-11 3:31 
GeneralRe: Make two listboxes have the same width Pin
Jean-Louis Leroy9-May-11 1:23
Jean-Louis Leroy9-May-11 1:23 
AnswerRe: Make two listboxes have the same width Pin
Renat Khabibulin9-May-11 1:26
Renat Khabibulin9-May-11 1:26 
Questionselect columns to load Pin
picasso25-May-11 18:49
picasso25-May-11 18:49 
QuestionHow to read the values from listbox Item source Pin
Rocky235-May-11 18:38
Rocky235-May-11 18:38 
HI,

In my application, i have to do something like that, checking the duplicate of data or checking wether the directive name in my listbox data template is empty or not,

Because when the user click on the button to insert new directive it has to check the listbox like wether the directive name is null or not, so can u tell me how to do it..

I have used a code like this,
public void LoadDirective()
        {
            //DerivedAttributeEntity oDAEEntity;
            listdata = new ObservableCollection<DADirective>();            
            SelectDirective = (DADirective)lbDirectiveList.SelectedItem;

            listdata.Add(new DADirective { DirectiveName = "Filter trading account", DirectiveDescription = "Rows will Trading account value to be filtered" });
            listdata.Add(new DADirective { DirectiveName = "Filter Counter party rows", DirectiveDescription = "Rows where counter party is null will be filtered" });
            listdata.Add(new DADirective { DirectiveName = "Filter USD currency records", DirectiveDescription = "Filter those rows where currency is USD" });

            lbDirectiveList.ItemsSource = listdata;
        }

private void btnNewDirectiveClicked(object sender, RoutedEventArgs e)
        {
            gDirectiveDetails.IsEnabled = true;
            gDerivedCondition.IsEnabled = true;
            DADirective dirdata = new DADirective { };
            
                   if (!listdata.Contains(dirdata))
            {
                    if (listdata.Count >= 0)
                    {
                        listdata.Add(new DADirective { });
                        lbDirectiveList.SelectedIndex = listdata.Count - 1;
                        txtDirectiveName.Focus();
                    }
                }
            
        }


This is my xaml code..

<ListBox Grid.Row="1" Grid.Column="2" x:Name="lbDirectiveList" ItemsSource="{Binding}" SelectionChanged="lbDirectiveList_SelectionChanged" MaxHeight="200" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Auto">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Margin="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="25" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>

                                        <TextBlock Name="tbDirName" Text="{Binding Path=DirectiveName, Mode=TwoWay}" Grid.Column="0" FontWeight="Bold" MinWidth="200"/>
                                        <TextBlock Text=" - " Grid.Column="1"/>
                                        <TextBlock Grid.Column="2" Name="tbDirDesc" Text="{Binding Path=DirectiveDescription, Mode=TwoWay}" />
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>


so how can to read the data in this listbox, i have used a foreach loop like foreach(var dir in listdata), but it is giving exception in case of directive insert, so is there any other way for this...
AnswerRe: How to read the values from listbox Item source Pin
Thanigainathan.S6-May-11 0:38
Thanigainathan.S6-May-11 0:38 
AnswerRe: How to read the values from listbox Item source Pin
Pete O'Hanlon6-May-11 1:12
mvePete O'Hanlon6-May-11 1:12 
QuestionWPF 3d iges, catpart or step modeling Pin
rafaeltejera5-May-11 11:17
rafaeltejera5-May-11 11:17 
QuestionCustom Control & Binding woe Pin
Super Lloyd4-May-11 15:36
Super Lloyd4-May-11 15:36 
AnswerRe: Custom Control & Binding woe Pin
Super Lloyd4-May-11 15:53
Super Lloyd4-May-11 15:53 
AnswerRe: Custom Control & Binding woe Pin
Super Lloyd4-May-11 15:59
Super Lloyd4-May-11 15:59 
QuestionBest Way To Do This Pin
Kevin Marois4-May-11 12:57
professionalKevin Marois4-May-11 12:57 
AnswerRe: Best Way To Do This Pin
Pete O'Hanlon4-May-11 13:17
mvePete O'Hanlon4-May-11 13:17 
GeneralRe: Best Way To Do This Pin
Kevin Marois4-May-11 13:21
professionalKevin Marois4-May-11 13:21 
GeneralRe: Best Way To Do This Pin
SledgeHammer014-May-11 14:19
SledgeHammer014-May-11 14:19 
AnswerRe: Best Way To Do This Pin
Renat Khabibulin4-May-11 16:55
Renat Khabibulin4-May-11 16:55 
AnswerRe: Best Way To Do This Pin
RichardGrimmer20-May-11 3:58
RichardGrimmer20-May-11 3:58 
QuestionWCF RIA / MVVM Question Pin
eddieangel4-May-11 11:33
eddieangel4-May-11 11:33 
AnswerRe: WCF RIA / MVVM Question Pin
Pete O'Hanlon4-May-11 12:25
mvePete O'Hanlon4-May-11 12:25 
QuestionHow do I databind a ListView to a property in child collection in WPF? Pin
B2C4-May-11 3:01
B2C4-May-11 3:01 
AnswerRe: How do I databind a ListView to a property in child collection in WPF? Pin
RichardGrimmer4-May-11 4:33
RichardGrimmer4-May-11 4:33 
GeneralRe: How do I databind a ListView to a property in child collection in WPF? Pin
B2C4-May-11 5:15
B2C4-May-11 5:15 

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.