Burzhuin
asked on
I need to clear List Box in MVVM panel.
I need to clear List Box in MVVM Panel to load different values. But there is no old method Clear, e.g. lstMine.Clear. I am new to MVVM and have no idea how to get around it.
ASKER
It is not working in MVVM panel.
Can you post the XAML and the code behind, thanks.
ASKER
I am getting this exception:
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead
ASKER
Here is XAML code:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace :Nwh.Membe r.Utility. ExceptionT racker.Vie ws" x:Class="SearchPanelView"
xmlns:local1="clr-namespac e:Nwh.Memb er.Utility .Exception Tracker.Vi ews"
xmlns:sys="clr-namespace:S ystem;asse mbly=mscor lib"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="1200">
<UserControl.Resources>
<local1:DatePickerConverte r x:Key="shortDateConverter" />
<!--<Style TargetType="DatePickerText Box">
<Setter Property="Background" Value="AliceBlue" />
</Style>-->
</UserControl.Resources>
<!--ScrollViewer HorizontalScrollBarVisibil ity="Visib le" VerticalScrollBarVisibilit y="Visible ">-->
<Grid>
<DockPanel LastChildFill="false" Margin="0,0,0,-36" >
<Expander ExpandDirection="Down" IsExpanded="True" DockPanel.Dock="Top" >
<!--Search Top Partion Below-->
<DockPanel DockPanel.Dock="Top" Margin="10, 0, 10, 0" LastChildFill="False" HorizontalAlignment="Stret ch" >
<DockPanel DockPanel.Dock="Left" Margin="0,0,0,0" LastChildFill="False" HorizontalAlignment="Stret ch" >
<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Stret ch" RenderTransformOrigin="0.5 ,0.5" VerticalAlignment="Stretch " MinHeight="150" >
<StackPanel Orientation="Vertical" >
<Label Content="Search Citeria" FontSize="14" FontWeight="Bold" Width="678" />
<TextBox Margin="10, 2, 0, 10" MinHeight="120" Text="{Binding SearchCriteria}" TextWrapping="Wrap" VerticalScrollBarVisibilit y="Auto" />
<!--<TextBox Margin=" 10, 5, 0, 10" Text="{Binding SearchResult}"></TextBox>- ->
</StackPanel>
</DockPanel>
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="10" >-->
<StackPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="10,0,0,0" HorizontalAlignment="Stret ch" >
<TextBlock FontSize="14" FontWeight="Bold">Sources< /TextBlock >
<RadioButton Content="834" HorizontalAlignment="Left" Margin="10,20,0,0" VerticalAlignment="Top" GroupName="grpType" Background="AliceBlue"
x:Name="opt834" RenderTransformOrigin="0.4 09,2.231" IsChecked="{Binding Is834Search}" />
<RadioButton Content="Xpress Workflow" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Background="AliceBlue"
GroupName="grpType" x:Name="optXPWF" IsChecked="{Binding IsWorkFlowSearch}"/>
<CheckBox Content="Include Unworkable" HorizontalAlignment="Left" Margin="10,20,0,0" VerticalAlignment="Top"
RenderTransformOrigin="-5. 377,-7.725 " IsChecked="{Binding IsUnworkable}"/>
</StackPanel>
<!--</Border>-->
<!--Source and Filters Panels-->
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="10" Margin="0, 5, 0, 5" >-->
<DockPanel DockPanel.Dock="Left" Margin="10, 0, 0, 0">
<StackPanel DockPanel.Dock="Bottom" Orientation="Vertical" >
<Label Content="Error Message" Margin="20, 0, 0, 0" />
<ComboBox Margin="20, 1, 5, 5" Width="550" x:Name="cboErrorMsg" Background="AliceBlue" VerticalAlignment="Stretch " HorizontalAlignment="Left"
ItemsSource="{Binding ErrorMessageList}" SelectedItem="{Binding SelectedErrorMessage }" SelectedIndex="0" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorMessage}" TextWrapping="Wrap" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="10,0,0,0" HorizontalAlignment="Stret ch" VerticalAlignment="Stretch " >
<TextBlock FontSize="14" FontWeight="Bold" Width="197">Filters</TextB lock>
<Label Content="Exception Type" HorizontalAlignment="Left" Margin="20,10,0,0" VerticalAlignment="Top" />
<!--Exception Type List in dropdown data setting -->
<ComboBox HorizontalAlignment="Left" Margin="20,1,0,0" VerticalAlignment="Top" x:Name="cboException" MinWidth="196" Background="AliceBlue"
ItemsSource="{Binding ExceptionTypeList}" SelectedItem="{Binding SelectedExceptionType}" IsReadOnly="True" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ExceptionTypeName }" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Content="Assigned To" HorizontalAlignment="Left" Margin="20,5,0,0" VerticalAlignment="Top" />
<ComboBox HorizontalAlignment="Left" Margin="20,5,0,0" VerticalAlignment="Top" x:Name="cboAssign" MinWidth="194" Background="AliceBlue"
ItemsSource="{Binding SearchableUserList}" SelectedItem="{Binding SelectedUser}"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="0,0,0,0" HorizontalAlignment="Stret ch" VerticalAlignment="top" Height="168" >
<Label Content="Status" HorizontalAlignment="Left" Margin="15,10,0,0" VerticalAlignment="Top" />
<ListBox HorizontalAlignment="Left" Height="110" Margin="15,2,0,0" VerticalAlignment="Top" x:Name="lboStatus" MinWidth="120"
ItemsSource="{Binding SearchableStatusList}" SelectionMode="Multiple" SelectionChanged="lboStatu s_Selectio nChanged" Background="AliceBlue" >
</ListBox>
</StackPanel>
<Grid DockPanel.Dock="Left" Margin="0,0,0,0" HorizontalAlignment="Stret ch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="Source" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Grid.Row="0" />
<ListBox HorizontalAlignment="Left" MinHeight="130" Margin="10,2,5,2" VerticalAlignment="Top" x:Name="lboSource" MinWidth="200" Grid.Row="1"
ItemsSource="{Binding DataSourceList}" SelectionMode="Multiple" SelectionChanged="lboSourc e_Selectio nChanged" Loaded="lboSource_Loaded" Background="AliceBlue" >
<ListBox.ItemTemplate >
<DataTemplate>
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="3" Margin="2, 2, 2, 2" >-->
<TextBlock Text="{Binding SourceName}" HorizontalAlignment="Stret ch" />
<!--</Border>-->
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</DockPanel>
<!--</Border>-->
</DockPanel>
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="10" Margin="0, 5, 0, 5" >-->
<DockPanel DockPanel.Dock="Left" LastChildFill="False" HorizontalAlignment="Stret ch" Margin="50, 10, 0, 0" >
<!--<Grid>
<Grid.RowDefinitions >
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>-->
<Grid Grid.Row="0" MinWidth="380">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--<Grid.ColumnDefinition s>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="0"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>- ->
<TextBlock Margin="10, 0, 0, 0" FontSize="14" FontWeight="Black" Grid.Row="0" HorizontalAlignment="Stret ch">Search Value</TextBlock>
<!--<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" >-->
<Label Content="Family ID" HorizontalAlignment="Stret ch" Margin="0,10,0,0" Grid.Row="1" />
<TextBox Height="23" TextWrapping="Wrap" VerticalAlignment="Top" MinWidth="225" x:Name="txtFamily"
Margin="70, 10, 0, 0" HorizontalAlignment="Left" Background="AliceBlue" Text="{Binding FamilyID}" Grid.Row="1" Width="310" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="MMIS ID" HorizontalAlignment="Stret ch" Margin="0,10,0,0" VerticalAlignment="Top" Grid.Row="2" Height="26" />
<TextBox HorizontalAlignment="Stret ch" Height="23" Margin="70,10,0,0" TextWrapping="Wrap" x:Name="txtMMISID" VerticalAlignment="Top" Grid.Row="2"
MinWidth="225" Background="AliceBlue" Text="{Binding MMISID}" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="SSN" HorizontalAlignment="Stret ch" Margin="0,10,0,0" VerticalAlignment="Top" Grid.Row="3" Height="26" />
<TextBox HorizontalAlignment="stret ch" Height="23" Margin="70,10,0,0" TextWrapping="Wrap" x:Name="txtSSN" VerticalAlignment="Top" Grid.Row="3"
MinWidth="225" Background="AliceBlue" Text="{Binding SSN}" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="Last Name" HorizontalAlignment="Stret ch" Margin="0,10,0,0" VerticalAlignment="Top" Grid.Row="4" Height="26" />
<TextBox HorizontalAlignment="Stret ch" Height="23" Margin="70,10,0,0" TextWrapping="Wrap" x:Name="txtLastName" VerticalAlignment="Top" Grid.Row="4"
MinWidth="225" Background="AliceBlue" Text="{Binding LastName}" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="Date Worked" HorizontalAlignment="Stret ch" Margin="0,10,0,0" VerticalAlignment="Top" Grid.Row="5" Height="26"/>
<!--<TextBox HorizontalAlignment="Left" Height="23" Margin="5,10,0,0" TextWrapping="Wrap" x:Name="txtDateWork" VerticalAlignment="Top" Grid.Row="5" Grid.Column="2"
MinWidth="125" Background="AliceBlue" Text="{Binding DateWork, Converter={StaticResource shortDateConverter }}" Width="125" />-->
<DatePicker HorizontalAlignment="Stret ch" Height="23" Margin="82,12,0,2" x:Name="txtDateWork" Grid.Row="5" Background="AliceBlue"
SelectedDate ="{Binding DateWork, Converter={StaticResource shortDateConverter}}" DisplayDate="{Binding WorkDisplayDate}"/>
<!--</StackPanel>-->
<!--<StackPanel DockPanel.Dock="Top">-->
<Label Content="Workflow ID" HorizontalAlignment="Stret ch" Margin="0, 10, 0, 0" VerticalAlignment="Top" Grid.Row="6" Height="25" />
<TextBox Margin="82,10,0,0" x:Name="txtWID" Grid.Row="6" Background="AliceBlue" Text="{Binding WorkflowID}" />
<TextBlock HorizontalAlignment="Cente r" FontSize="14" FontWeight="Black" Grid.Row="7" Margin="46,0,20,0" >Process Date</TextBlock>
<!--</StackPanel>-->
<!--<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" >-->
<Label Content="From" HorizontalAlignment="Stret ch" Margin="10,2,0,0" VerticalAlignment="Top" Grid.Row="8" Grid.Column="0" Height="26" />
<!--<TextBox HorizontalAlignment="Left" Height="23" Margin="45,5,0,0" TextWrapping="Wrap" x:Name="txtFromDate" VerticalAlignment="Top" Grid.Row="7"
MinWidth="100" Background="AliceBlue" Text="{Binding FromDate}" Width="100"/>
<Button HorizontalAlignment="Left" Margin="0,5" Content="..." x:Name="btnCalendar1" Width="25" Grid.Row="7" Grid.Column="2"/>-->
<DatePicker HorizontalAlignment="Stret ch" Height="23" Grid.Row="8" SelectedDate="{Binding FromDate, Converter={StaticResource shortDateConverter }}"
DisplayDate="{Binding ProcFromDisplayDate}" Margin="60,2, 200,0" Background="AliceBlue" />
<Label Content="To" HorizontalAlignment="Left" Margin="180,5,0,0" VerticalAlignment="Top" Grid.Row="8" Height="26" />
<!--<TextBox HorizontalAlignment="Left" Height="23" Margin="90,5,0,0" TextWrapping="Wrap" x:Name="txtToDate" VerticalAlignment="Top" Grid.Row="7" Grid.Column="2"
MinWidth="100" Background="AliceBlue" Text="{Binding ToDate}" Width="100"/>
<Button HorizontalAlignment="Left" Margin="195,5,0,5" x:Name="btnCalendar2" Width="25" Content="...." Grid.Row="7" Grid.Column="2"/>-->
<DatePicker HorizontalAlignment="Stret ch" Height="23" Margin="221,6,0,1" DisplayDate="{Binding ProcToDisplayDate}"
SelectedDate ="{Binding ToDate, Converter={StaticResource shortDateConverter }}" Grid.Row="8" />
<Label Content="Environment" HorizontalAlignment="Stret ch" Margin="0,0,350,0" x:Name="lblEnv" VerticalAlignment="Top" Grid.Row="9" Grid.Column="0" Height="26" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Button Content="Search" Margin="60,10,200,10" x:Name="btnSearch" Click="btnSearch_Click" Grid.Row="9" />
<!--="{Binding CmdSearch}" /> Command="{Binding ResetAction}" -->
<Button Content="Reset" Margin="221,10,53,10" x:Name="btnReset" Click="btnReset_Click" Grid.Row="9" />
<Button Content="Show Env" Margin="100,60,100,-12" x:Name="btnShowEnv" Click="btnShowEnv_Click" Grid.Row="9" />
<!--</StackPanel>-->
</Grid>
<!--</Grid>-->
</DockPanel>
<!--</Border>-->
<Popup x:Name="popUp1" IsOpen="{Binding IsBusy}" Placement="Bottom" AllowsTransparency="True" PopupAnimation="Slide" VerticalOffset="-30" HorizontalOffset="70" >
<!--<Grid>-->
<!--<StackPanel Height="150" Width="200" Background="Yellow" >-->
<TextBlock Text="Searching Exception Trackers..." Background="Yellow" HorizontalAlignment="Cente r" VerticalAlignment="Center" FontSize="16" Margin=" 800, 0, 0, 0" Width="240" />
<!--</StackPanel>-->
<!--<ProgressBar HorizontalAlignment="Left"
Name="progressBar1" Height="25"
VerticalAlignment="Center" Width="130"
Foreground="#FF3EA3EA"
Value="{Binding ElementName=textBox1, Path=Text.Length, Mode=OneTime}"
Maximum="140" ForceCursor="False" />-->
<!--</Grid>-->
</Popup>
</DockPanel>
</Expander>
<!--
<DockPanel DockPanel.Dock="Top" LastChildFill="False" Margin="0, 0, 0, 0" VerticalAlignment="Stretch " >
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="NavajoWhite" Height="40" HorizontalAlignment="Stret ch" >
<TextBlock Margin="10, 10, 0, 0">Edit all entries in column</TextBlock>
<CheckBox Margin="60, 10, 0, 0" x:Name="chkBatchStatus" />
<ComboBox Margin="5,5,0,10" MinWidth="150" x:Name="cboBatchStatus" />
<CheckBox Margin="60, 10, 0, 0" x:Name="chkBatchUser" />
<ComboBox Margin="5,5,0,10" MinWidth="150" x:Name="cboBatchUser" />
<Button Content="Batch Update" x:Name="btnBatchUpdate" Margin="360,5,0,10" Width="99" Click="btnBatchUpdate_Clic k" />
</StackPanel>
</DockPanel>
-->
<!--<StackPanel DockPanel.Dock="Bottom" Background="NavajoWhite" Height="45" Orientation="Horizontal" HorizontalAlignment="Stret ch" >
<Button Margin="80, 5, 0, 0" Content="Detail" x:Name="btnDetail" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="History" x:Name="btnHistory" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="Export" x:Name="btnExport" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="Save" x:Name="btnSave" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="Cancel" x:Name="btnCancel" Width="100" Height="25"/>
</StackPanel>-->
<Border MinHeight="350" MinWidth="1190" Margin="5,0" BorderBrush="DarkBlue" BorderThickness="3" CornerRadius="10" Height="471" VerticalAlignment="Top">
<DockPanel DockPanel.Dock="Top" x:Name="pnl834Result" Visibility="Visible" Margin="0,0,0,83" VerticalAlignment="Stretch " HorizontalAlignment="Stret ch" >
<!--<local:EDI834SearchRes ults VerticalAlignment="Top" x:Name="grid834Result"/>-- >
</DockPanel>
</Border>
<!--<DockPanel DockPanel.Dock="Top" x:Name="pnlWFResult" Visibility="Hidden" Margin="0, 0, 0, 0" >
<local:XPWorkflowResultsVi ew x:Name="gridWFResult" />
</DockPanel>-->
</DockPanel>
<!--
<DockPanel Margin="0,35,0,0" LastChildFill="False" VerticalAlignment="Top" HorizontalAlignment="Left" Height=" 30" >
</DockPanel>-->
<!--<DockPanel Margin="770, 0, 0, 0" LastChildFill="False" VerticalAlignment="Top" HorizontalAlignment="Left" Height=" 30" >
</DockPanel>-->
<!--
<TextBlock HorizontalAlignment="Left" Margin="26,245,0,0" TextWrapping="Wrap"
x:Name="txtSeaarchConditio n" VerticalAlignment="Top" Height="129" Width="721" Background="AntiqueWhite"/ >
<Button Content="Searh" HorizontalAlignment="Left" Margin="837,277,0,0" VerticalAlignment="Top" MinWidth="105" x:Name="btnSearch"/>
-->
</Grid>
</UserControl>
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace
xmlns:local1="clr-namespac
xmlns:sys="clr-namespace:S
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="1200">
<UserControl.Resources>
<local1:DatePickerConverte
<!--<Style TargetType="DatePickerText
<Setter Property="Background" Value="AliceBlue" />
</Style>-->
</UserControl.Resources>
<!--ScrollViewer HorizontalScrollBarVisibil
<Grid>
<DockPanel LastChildFill="false" Margin="0,0,0,-36" >
<Expander ExpandDirection="Down" IsExpanded="True" DockPanel.Dock="Top" >
<!--Search Top Partion Below-->
<DockPanel DockPanel.Dock="Top" Margin="10, 0, 10, 0" LastChildFill="False" HorizontalAlignment="Stret
<DockPanel DockPanel.Dock="Left" Margin="0,0,0,0" LastChildFill="False" HorizontalAlignment="Stret
<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Stret
<StackPanel Orientation="Vertical" >
<Label Content="Search Citeria" FontSize="14" FontWeight="Bold" Width="678" />
<TextBox Margin="10, 2, 0, 10" MinHeight="120" Text="{Binding SearchCriteria}" TextWrapping="Wrap" VerticalScrollBarVisibilit
<!--<TextBox Margin=" 10, 5, 0, 10" Text="{Binding SearchResult}"></TextBox>-
</StackPanel>
</DockPanel>
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="10" >-->
<StackPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="10,0,0,0" HorizontalAlignment="Stret
<TextBlock FontSize="14" FontWeight="Bold">Sources<
<RadioButton Content="834" HorizontalAlignment="Left"
x:Name="opt834" RenderTransformOrigin="0.4
<RadioButton Content="Xpress Workflow" HorizontalAlignment="Left"
GroupName="grpType" x:Name="optXPWF" IsChecked="{Binding IsWorkFlowSearch}"/>
<CheckBox Content="Include Unworkable" HorizontalAlignment="Left"
RenderTransformOrigin="-5.
</StackPanel>
<!--</Border>-->
<!--Source and Filters Panels-->
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="10" Margin="0, 5, 0, 5" >-->
<DockPanel DockPanel.Dock="Left" Margin="10, 0, 0, 0">
<StackPanel DockPanel.Dock="Bottom" Orientation="Vertical" >
<Label Content="Error Message" Margin="20, 0, 0, 0" />
<ComboBox Margin="20, 1, 5, 5" Width="550" x:Name="cboErrorMsg" Background="AliceBlue" VerticalAlignment="Stretch
ItemsSource="{Binding ErrorMessageList}" SelectedItem="{Binding SelectedErrorMessage }" SelectedIndex="0" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ErrorMessage}" TextWrapping="Wrap" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="10,0,0,0" HorizontalAlignment="Stret
<TextBlock FontSize="14" FontWeight="Bold" Width="197">Filters</TextB
<Label Content="Exception Type" HorizontalAlignment="Left"
<!--Exception Type List in dropdown data setting -->
<ComboBox HorizontalAlignment="Left"
ItemsSource="{Binding ExceptionTypeList}" SelectedItem="{Binding SelectedExceptionType}" IsReadOnly="True" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ExceptionTypeName }" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Content="Assigned To" HorizontalAlignment="Left"
<ComboBox HorizontalAlignment="Left"
ItemsSource="{Binding SearchableUserList}" SelectedItem="{Binding SelectedUser}"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="0,0,0,0" HorizontalAlignment="Stret
<Label Content="Status" HorizontalAlignment="Left"
<ListBox HorizontalAlignment="Left"
ItemsSource="{Binding SearchableStatusList}" SelectionMode="Multiple" SelectionChanged="lboStatu
</ListBox>
</StackPanel>
<Grid DockPanel.Dock="Left" Margin="0,0,0,0" HorizontalAlignment="Stret
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="Source" HorizontalAlignment="Left"
<ListBox HorizontalAlignment="Left"
ItemsSource="{Binding DataSourceList}" SelectionMode="Multiple" SelectionChanged="lboSourc
<ListBox.ItemTemplate >
<DataTemplate>
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="3" Margin="2, 2, 2, 2" >-->
<TextBlock Text="{Binding SourceName}" HorizontalAlignment="Stret
<!--</Border>-->
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</DockPanel>
<!--</Border>-->
</DockPanel>
<!--<Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="10" Margin="0, 5, 0, 5" >-->
<DockPanel DockPanel.Dock="Left" LastChildFill="False" HorizontalAlignment="Stret
<!--<Grid>
<Grid.RowDefinitions >
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>-->
<Grid Grid.Row="0" MinWidth="380">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--<Grid.ColumnDefinition
<ColumnDefinition Width="150" />
<ColumnDefinition Width="0"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>-
<TextBlock Margin="10, 0, 0, 0" FontSize="14" FontWeight="Black" Grid.Row="0" HorizontalAlignment="Stret
<!--<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" >-->
<Label Content="Family ID" HorizontalAlignment="Stret
<TextBox Height="23" TextWrapping="Wrap" VerticalAlignment="Top" MinWidth="225" x:Name="txtFamily"
Margin="70, 10, 0, 0" HorizontalAlignment="Left"
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="MMIS ID" HorizontalAlignment="Stret
<TextBox HorizontalAlignment="Stret
MinWidth="225" Background="AliceBlue" Text="{Binding MMISID}" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="SSN" HorizontalAlignment="Stret
<TextBox HorizontalAlignment="stret
MinWidth="225" Background="AliceBlue" Text="{Binding SSN}" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="Last Name" HorizontalAlignment="Stret
<TextBox HorizontalAlignment="Stret
MinWidth="225" Background="AliceBlue" Text="{Binding LastName}" />
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Label Content="Date Worked" HorizontalAlignment="Stret
<!--<TextBox HorizontalAlignment="Left"
MinWidth="125" Background="AliceBlue" Text="{Binding DateWork, Converter={StaticResource shortDateConverter }}" Width="125" />-->
<DatePicker HorizontalAlignment="Stret
SelectedDate ="{Binding DateWork, Converter={StaticResource shortDateConverter}}" DisplayDate="{Binding WorkDisplayDate}"/>
<!--</StackPanel>-->
<!--<StackPanel DockPanel.Dock="Top">-->
<Label Content="Workflow ID" HorizontalAlignment="Stret
<TextBox Margin="82,10,0,0" x:Name="txtWID" Grid.Row="6" Background="AliceBlue" Text="{Binding WorkflowID}" />
<TextBlock HorizontalAlignment="Cente
<!--</StackPanel>-->
<!--<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" >-->
<Label Content="From" HorizontalAlignment="Stret
<!--<TextBox HorizontalAlignment="Left"
MinWidth="100" Background="AliceBlue" Text="{Binding FromDate}" Width="100"/>
<Button HorizontalAlignment="Left"
<DatePicker HorizontalAlignment="Stret
DisplayDate="{Binding ProcFromDisplayDate}" Margin="60,2, 200,0" Background="AliceBlue" />
<Label Content="To" HorizontalAlignment="Left"
<!--<TextBox HorizontalAlignment="Left"
MinWidth="100" Background="AliceBlue" Text="{Binding ToDate}" Width="100"/>
<Button HorizontalAlignment="Left"
<DatePicker HorizontalAlignment="Stret
SelectedDate ="{Binding ToDate, Converter={StaticResource shortDateConverter }}" Grid.Row="8" />
<Label Content="Environment" HorizontalAlignment="Stret
<!--</StackPanel>-->
<!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" >-->
<Button Content="Search" Margin="60,10,200,10" x:Name="btnSearch" Click="btnSearch_Click" Grid.Row="9" />
<!--="{Binding CmdSearch}" /> Command="{Binding ResetAction}" -->
<Button Content="Reset" Margin="221,10,53,10" x:Name="btnReset" Click="btnReset_Click" Grid.Row="9" />
<Button Content="Show Env" Margin="100,60,100,-12" x:Name="btnShowEnv" Click="btnShowEnv_Click" Grid.Row="9" />
<!--</StackPanel>-->
</Grid>
<!--</Grid>-->
</DockPanel>
<!--</Border>-->
<Popup x:Name="popUp1" IsOpen="{Binding IsBusy}" Placement="Bottom" AllowsTransparency="True" PopupAnimation="Slide" VerticalOffset="-30" HorizontalOffset="70" >
<!--<Grid>-->
<!--<StackPanel Height="150" Width="200" Background="Yellow" >-->
<TextBlock Text="Searching Exception Trackers..." Background="Yellow" HorizontalAlignment="Cente
<!--</StackPanel>-->
<!--<ProgressBar HorizontalAlignment="Left"
Name="progressBar1" Height="25"
VerticalAlignment="Center"
Foreground="#FF3EA3EA"
Value="{Binding ElementName=textBox1, Path=Text.Length, Mode=OneTime}"
Maximum="140" ForceCursor="False" />-->
<!--</Grid>-->
</Popup>
</DockPanel>
</Expander>
<!--
<DockPanel DockPanel.Dock="Top" LastChildFill="False" Margin="0, 0, 0, 0" VerticalAlignment="Stretch
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="NavajoWhite" Height="40" HorizontalAlignment="Stret
<TextBlock Margin="10, 10, 0, 0">Edit all entries in column</TextBlock>
<CheckBox Margin="60, 10, 0, 0" x:Name="chkBatchStatus" />
<ComboBox Margin="5,5,0,10" MinWidth="150" x:Name="cboBatchStatus" />
<CheckBox Margin="60, 10, 0, 0" x:Name="chkBatchUser" />
<ComboBox Margin="5,5,0,10" MinWidth="150" x:Name="cboBatchUser" />
<Button Content="Batch Update" x:Name="btnBatchUpdate" Margin="360,5,0,10" Width="99" Click="btnBatchUpdate_Clic
</StackPanel>
</DockPanel>
-->
<!--<StackPanel DockPanel.Dock="Bottom" Background="NavajoWhite" Height="45" Orientation="Horizontal" HorizontalAlignment="Stret
<Button Margin="80, 5, 0, 0" Content="Detail" x:Name="btnDetail" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="History" x:Name="btnHistory" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="Export" x:Name="btnExport" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="Save" x:Name="btnSave" Width="100" Height="25"/>
<Button Margin="80, 5, 0, 0" Content="Cancel" x:Name="btnCancel" Width="100" Height="25"/>
</StackPanel>-->
<Border MinHeight="350" MinWidth="1190" Margin="5,0" BorderBrush="DarkBlue" BorderThickness="3" CornerRadius="10" Height="471" VerticalAlignment="Top">
<DockPanel DockPanel.Dock="Top" x:Name="pnl834Result" Visibility="Visible" Margin="0,0,0,83" VerticalAlignment="Stretch
<!--<local:EDI834SearchRes
</DockPanel>
</Border>
<!--<DockPanel DockPanel.Dock="Top" x:Name="pnlWFResult" Visibility="Hidden" Margin="0, 0, 0, 0" >
<local:XPWorkflowResultsVi
</DockPanel>-->
</DockPanel>
<!--
<DockPanel Margin="0,35,0,0" LastChildFill="False" VerticalAlignment="Top" HorizontalAlignment="Left"
</DockPanel>-->
<!--<DockPanel Margin="770, 0, 0, 0" LastChildFill="False" VerticalAlignment="Top" HorizontalAlignment="Left"
</DockPanel>-->
<!--
<TextBlock HorizontalAlignment="Left"
x:Name="txtSeaarchConditio
<Button Content="Searh" HorizontalAlignment="Left"
-->
</Grid>
</UserControl>
ASKER
Here is the code behind it:
Imports Nwh.Member.Utility.Excepti onTracker. Models
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class SearchPanelView
Private stOutput As String
Private Sub btnSearch_Click(sender As Object, e As Windows.RoutedEventArgs)
'Me.Height = 300
'Me.Width = 300
Try
Dim bgWorker As New BackgroundWorker
AddHandler bgWorker.DoWork, AddressOf DoSearch
AddHandler bgWorker.RunWorkerComplete d, AddressOf DoSearchComplete
popUp1.IsOpen = True
Dim searchVM As SearchPanelVM = Me.DataContext
stOutput = String.Empty
bgWorker.RunWorkerAsync(se archVM)
Catch ex As Exception
Utility.delWriteToErrorLog ("SearchPa nelView.bt nSeach_Cli ck", ex)
System.Windows.MessageBox. Show(ex.Me ssage)
End Try
End Sub
''' <summary>
''' Run the search in background worker
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub DoSearch(sender As Object, e As DoWorkEventArgs)
Try
Dim searchVM As SearchPanelVM = e.Argument
Dim resultVM As SearchResultsVM = searchVM.GetSearchResult(s tOutput)
e.Result = resultVM
Catch ex As Exception
System.Windows.MessageBox. Show(ex.Me ssage)
Utility.delWriteToErrorLog ("SearchPa nelView.Do Search", ex)
End Try
End Sub
''' <summary>
''' Output the search result to frontend after background worker finish the search
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub DoSearchComplete(sender As Object, e As RunWorkerCompletedEventArg s)
Try
Dim searchVM As SearchPanelVM = Me.DataContext
If Not String.IsNullOrEmpty(stOut put) Then
popUp1.IsOpen = False
System.Windows.MessageBox. Show(stOut put)
Return
End If
Dim resultVM As SearchResultsVM = e.Result
pnl834Result.Visibility = Windows.Visibility.Visible
' Dim gridResult As Windows.UIElement
pnl834Result.Children.Clea r()
If resultVM.searchResultTrack ers.Count = 0 Then
'stOutput = "No result found"
popUp1.IsOpen = False
System.Windows.MessageBox. Show("No result found")
Return
End If
Dim grid834 As New EDI834SearchResults
If searchVM.Is834Search Then
grid834.IsBatchChange = True
grid834.DataContext = resultVM
pnl834Result.Children.Add( grid834)
Else
Dim gridWF As New XPWorkflowResultsView
gridWF.DataContext = resultVM
pnl834Result.Children.Add( gridWF)
End If
resultVM.TotalResults = String.Format("Total Records: {0}", resultVM.searchResultTrack ers.Count. ToString)
'String.Format("1 - {0} Records of Total {0} Records", resultVM.searchResultTrack ers.Count. ToString)
pnl834Result.DataContext = resultVM
grid834.IsBatchChange = False
popUp1.IsOpen = False
Catch ex As Exception
Utility.delWriteToErrorLog ("SearchPa nelView.Do SearchComp lete", ex)
'If popUp1.IsOpen Then
' popUp1.IsOpen = False
'End If
End Try
End Sub
Private Sub lboSource_SelectionChanged (sender As Object, e As Windows.Controls.Selection ChangedEve ntArgs)
'Dim lstSources As New List(Of ExceptionTrackerSource)
'Dim iAllSources As Boolean = False
'
' If lboSource.SelectedItems.Co unt > 0 Then
' For Each itm In lboSource.SelectedItems
'Dim st As ExceptionTrackerSource = DirectCast(itm, ExceptionTrackerSource)
' ExceptionTrackerSource.RIF LAG = frmSearch.isRIET
' If st.EqualTo(ExceptionTracke rSource.Ge tAllSource ) Then
' iAllSources = True
' lstSources = New List(Of ExceptionTrackerSource)()
' lstSources.Add(st)
' Exit For
' End If
' lstSources.Add(st)
' Next
' End If
' If iAllSources And lboSource.SelectedItems.Co unt > 1 Then
' lboSource.UnselectAll()
' lboSource.SelectedIndex = 0
' Else
' lstSources = New List(Of ExceptionTrackerSource)()
' For Each itm1 In lboSource.SelectedItems
'Dim st1 As ExceptionTrackerSource = DirectCast(itm1, ExceptionTrackerSource)
' lstSources.Add(st1)
' Next
' End If
'Dim spVM As SearchPanelVM = Me.DataContext
' spVM.SelectedFileSources = lstSources
End Sub
Private Sub lboStatus_SelectionChanged (sender As Object, e As Windows.Controls.Selection ChangedEve ntArgs)
' System.Windows.MessageBox. Show(sende r.GetType. ToString() )
Dim lstStatus As New List(Of ExceptionTrackerStatus)
Dim iAllStatus As Boolean = False
' Dim totalSelectedStatus = lboSource.SelectedItems.Co unt
For Each itm In lboStatus.SelectedItems
Dim stu As ExceptionTrackerStatus = DirectCast(itm, ExceptionTrackerStatus)
If stu.EqualTo(ExceptionTrack erStatus.A llStatusSt atus) Then
iAllStatus = True
lstStatus = New List(Of ExceptionTrackerStatus)
lstStatus.Add(stu)
Exit For
End If
'lstStatus.Add(stu)
Next
If iAllStatus And lboStatus.SelectedItems.Co unt > 1 Then
lboStatus.UnselectAll()
lboStatus.SelectedIndex = 0
'lboStatus.SelectedValue = ExceptionTrackerStatus.All StatusStat us
' lboStatus.SelectedItem = lstStatus(0)
Else
lstStatus = New List(Of ExceptionTrackerStatus)()
For Each itm2 In lboStatus.SelectedItems
Dim stu2 As ExceptionTrackerStatus = DirectCast(itm2, ExceptionTrackerStatus)
lstStatus.Add(stu2)
Next
End If
Dim spVM As SearchPanelVM = Me.DataContext
spVM.SelectedStatuses = lstStatus
End Sub
'Private Sub btnBatchUpdate_Click(sende r As Object, e As Windows.RoutedEventArgs)
' If pnl834Result.Children.Coun t = 0 Then
' Return
' End If
' Dim resultVM As SearchResultsVM = pnl834Result.DataContext
' System.Windows.MessageBox. Show(resul tVM.Select edTrackerV Ms.Count.T oString())
' 'Dim obj As Object = pnl834Result.Children(0)
'End Sub
Private Sub btnLayout_Click(sender As Object, e As Windows.RoutedEventArgs)
'Me.Height = 300
'Me.Width = 300
'Dim md As New SearchPanelView
'md.Height = 300
'md.Width = 300
End Sub
Private Sub btnReset_Click(sender As Object, e As Windows.RoutedEventArgs)
Dim iResult = System.Windows.MessageBox. Show("Do you want to clear all search conditions?", "Clear Search Result", vbYesNo)
If iResult = Windows.MessageBoxResult.Y es Then
Dim spVM As SearchPanelVM = Me.DataContext
spVM.DoReset()
lboStatus.UnselectAll()
lboSource.UnselectAll()
pnl834Result.Children.Clea r()
End If
End Sub
Private Sub btnShowEnv_Click(sender As Object, e As Windows.RoutedEventArgs)
If frmSearch.isRIET = True Then
Dim cnt As Integer
MsgBox("Hello from Donald!")
ExceptionTrackerSource.RIF LAG = True
'Dim spVM As SearchPanelVM = Me.DataContext
'Dim lstSources As New List(Of ExceptionTrackerSource)
'For Each Item In lstSources
'lboSource.ClearValue(lboS ource.Item s.Clear) '= ExceptionTrackerSource.Cle arAllSourc e
'Next
'spVM.DoReset()
'lboSource.DataContext = Me.DataContext
cnt = lboSource.Items.Count
MsgBox("Over all there are " & cnt & " items in lboSource ListBox")
For i = 0 To lboSource.Items.Count - 1
'lboSource.ItemsSource.Get Type()
lboSource.Items.RemoveAt(i )
Next
'lstSources = New List(Of ExceptionTrackerSource)
'MsgBox(lstSources.Count)
'lstSources.Clear()
'MsgBox(lstSources.Count)
'lblEnv.Content = "True!"
Else
lblEnv.Content = "False!"
End If
End Sub
Private Sub lboSource_Loaded(sender As Object, e As Windows.RoutedEventArgs) Handles lboSource.Loaded
'If frmSearch.isRIET = True Then
Dim lstSources As New List(Of ExceptionTrackerSource)
'Dim st As New ExceptionTrackerSource = ExceptionTrackerSource
'Dim st As ExceptionTrackerSource = DirectCast(item, ExceptionTrackerSource)
'lboSource.Items.Clear()
ExceptionTrackerSource.RIF LAG = frmSearch.isRIET
lstSources.Clear()
'Dim iAllSources As Boolean = False
'ExceptionTrackerSource.RI FLAG = frmSearch.isRIET
'Dim st As New ExceptionTrackerSource = ExceptionTrackerSource
'Dim st As ExceptionTrackerSource = DirectCast(itm, ExceptionTrackerSource)
'ExceptionTrackerSource.RI FLAG = frmSearch.isRIET
'If st.EqualTo(ExceptionTracke rSource.Ge tAllSource ) Then
'iAllSources = True
lstSources = New List(Of ExceptionTrackerSource)
'lstSources.Clear()
'lstSources.Add(st)
'End If
'MsgBox("The value of ExceptationTrackerSource property is " & ExceptionTrackerSource.RIF LAG & "!")
'End If
Dim spVM As SearchPanelVM = Me.DataContext
spVM.SelectedFileSources = lstSources
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
Imports Nwh.Member.Utility.Excepti
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class SearchPanelView
Private stOutput As String
Private Sub btnSearch_Click(sender As Object, e As Windows.RoutedEventArgs)
'Me.Height = 300
'Me.Width = 300
Try
Dim bgWorker As New BackgroundWorker
AddHandler bgWorker.DoWork, AddressOf DoSearch
AddHandler bgWorker.RunWorkerComplete
popUp1.IsOpen = True
Dim searchVM As SearchPanelVM = Me.DataContext
stOutput = String.Empty
bgWorker.RunWorkerAsync(se
Catch ex As Exception
Utility.delWriteToErrorLog
System.Windows.MessageBox.
End Try
End Sub
''' <summary>
''' Run the search in background worker
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub DoSearch(sender As Object, e As DoWorkEventArgs)
Try
Dim searchVM As SearchPanelVM = e.Argument
Dim resultVM As SearchResultsVM = searchVM.GetSearchResult(s
e.Result = resultVM
Catch ex As Exception
System.Windows.MessageBox.
Utility.delWriteToErrorLog
End Try
End Sub
''' <summary>
''' Output the search result to frontend after background worker finish the search
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub DoSearchComplete(sender As Object, e As RunWorkerCompletedEventArg
Try
Dim searchVM As SearchPanelVM = Me.DataContext
If Not String.IsNullOrEmpty(stOut
popUp1.IsOpen = False
System.Windows.MessageBox.
Return
End If
Dim resultVM As SearchResultsVM = e.Result
pnl834Result.Visibility = Windows.Visibility.Visible
' Dim gridResult As Windows.UIElement
pnl834Result.Children.Clea
If resultVM.searchResultTrack
'stOutput = "No result found"
popUp1.IsOpen = False
System.Windows.MessageBox.
Return
End If
Dim grid834 As New EDI834SearchResults
If searchVM.Is834Search Then
grid834.IsBatchChange = True
grid834.DataContext = resultVM
pnl834Result.Children.Add(
Else
Dim gridWF As New XPWorkflowResultsView
gridWF.DataContext = resultVM
pnl834Result.Children.Add(
End If
resultVM.TotalResults = String.Format("Total Records: {0}", resultVM.searchResultTrack
'String.Format("1 - {0} Records of Total {0} Records", resultVM.searchResultTrack
pnl834Result.DataContext = resultVM
grid834.IsBatchChange = False
popUp1.IsOpen = False
Catch ex As Exception
Utility.delWriteToErrorLog
'If popUp1.IsOpen Then
' popUp1.IsOpen = False
'End If
End Try
End Sub
Private Sub lboSource_SelectionChanged
'Dim lstSources As New List(Of ExceptionTrackerSource)
'Dim iAllSources As Boolean = False
'
' If lboSource.SelectedItems.Co
' For Each itm In lboSource.SelectedItems
'Dim st As ExceptionTrackerSource = DirectCast(itm, ExceptionTrackerSource)
' ExceptionTrackerSource.RIF
' If st.EqualTo(ExceptionTracke
' iAllSources = True
' lstSources = New List(Of ExceptionTrackerSource)()
' lstSources.Add(st)
' Exit For
' End If
' lstSources.Add(st)
' Next
' End If
' If iAllSources And lboSource.SelectedItems.Co
' lboSource.UnselectAll()
' lboSource.SelectedIndex = 0
' Else
' lstSources = New List(Of ExceptionTrackerSource)()
' For Each itm1 In lboSource.SelectedItems
'Dim st1 As ExceptionTrackerSource = DirectCast(itm1, ExceptionTrackerSource)
' lstSources.Add(st1)
' Next
' End If
'Dim spVM As SearchPanelVM = Me.DataContext
' spVM.SelectedFileSources = lstSources
End Sub
Private Sub lboStatus_SelectionChanged
' System.Windows.MessageBox.
Dim lstStatus As New List(Of ExceptionTrackerStatus)
Dim iAllStatus As Boolean = False
' Dim totalSelectedStatus = lboSource.SelectedItems.Co
For Each itm In lboStatus.SelectedItems
Dim stu As ExceptionTrackerStatus = DirectCast(itm, ExceptionTrackerStatus)
If stu.EqualTo(ExceptionTrack
iAllStatus = True
lstStatus = New List(Of ExceptionTrackerStatus)
lstStatus.Add(stu)
Exit For
End If
'lstStatus.Add(stu)
Next
If iAllStatus And lboStatus.SelectedItems.Co
lboStatus.UnselectAll()
lboStatus.SelectedIndex = 0
'lboStatus.SelectedValue = ExceptionTrackerStatus.All
' lboStatus.SelectedItem = lstStatus(0)
Else
lstStatus = New List(Of ExceptionTrackerStatus)()
For Each itm2 In lboStatus.SelectedItems
Dim stu2 As ExceptionTrackerStatus = DirectCast(itm2, ExceptionTrackerStatus)
lstStatus.Add(stu2)
Next
End If
Dim spVM As SearchPanelVM = Me.DataContext
spVM.SelectedStatuses = lstStatus
End Sub
'Private Sub btnBatchUpdate_Click(sende
' If pnl834Result.Children.Coun
' Return
' End If
' Dim resultVM As SearchResultsVM = pnl834Result.DataContext
' System.Windows.MessageBox.
' 'Dim obj As Object = pnl834Result.Children(0)
'End Sub
Private Sub btnLayout_Click(sender As Object, e As Windows.RoutedEventArgs)
'Me.Height = 300
'Me.Width = 300
'Dim md As New SearchPanelView
'md.Height = 300
'md.Width = 300
End Sub
Private Sub btnReset_Click(sender As Object, e As Windows.RoutedEventArgs)
Dim iResult = System.Windows.MessageBox.
If iResult = Windows.MessageBoxResult.Y
Dim spVM As SearchPanelVM = Me.DataContext
spVM.DoReset()
lboStatus.UnselectAll()
lboSource.UnselectAll()
pnl834Result.Children.Clea
End If
End Sub
Private Sub btnShowEnv_Click(sender As Object, e As Windows.RoutedEventArgs)
If frmSearch.isRIET = True Then
Dim cnt As Integer
MsgBox("Hello from Donald!")
ExceptionTrackerSource.RIF
'Dim spVM As SearchPanelVM = Me.DataContext
'Dim lstSources As New List(Of ExceptionTrackerSource)
'For Each Item In lstSources
'lboSource.ClearValue(lboS
'Next
'spVM.DoReset()
'lboSource.DataContext = Me.DataContext
cnt = lboSource.Items.Count
MsgBox("Over all there are " & cnt & " items in lboSource ListBox")
For i = 0 To lboSource.Items.Count - 1
'lboSource.ItemsSource.Get
lboSource.Items.RemoveAt(i
Next
'lstSources = New List(Of ExceptionTrackerSource)
'MsgBox(lstSources.Count)
'lstSources.Clear()
'MsgBox(lstSources.Count)
'lblEnv.Content = "True!"
Else
lblEnv.Content = "False!"
End If
End Sub
Private Sub lboSource_Loaded(sender As Object, e As Windows.RoutedEventArgs) Handles lboSource.Loaded
'If frmSearch.isRIET = True Then
Dim lstSources As New List(Of ExceptionTrackerSource)
'Dim st As New ExceptionTrackerSource = ExceptionTrackerSource
'Dim st As ExceptionTrackerSource = DirectCast(item, ExceptionTrackerSource)
'lboSource.Items.Clear()
ExceptionTrackerSource.RIF
lstSources.Clear()
'Dim iAllSources As Boolean = False
'ExceptionTrackerSource.RI
'Dim st As New ExceptionTrackerSource = ExceptionTrackerSource
'Dim st As ExceptionTrackerSource = DirectCast(itm, ExceptionTrackerSource)
'ExceptionTrackerSource.RI
'If st.EqualTo(ExceptionTracke
'iAllSources = True
lstSources = New List(Of ExceptionTrackerSource)
'lstSources.Clear()
'lstSources.Add(st)
'End If
'MsgBox("The value of ExceptationTrackerSource property is " & ExceptionTrackerSource.RIF
'End If
Dim spVM As SearchPanelVM = Me.DataContext
spVM.SelectedFileSources = lstSources
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
OK, First when posting code snippets use the CODE icon on the toolbox. First paste your code to the textbox and then highlight the code and then click the CODE icon on the toolbox. It helps those who are trying to help you.
Second I did a searched on the code and could not find a ListBox called lstMine. Please state what parts of the code you are having issues with.
Second I did a searched on the code and could not find a ListBox called lstMine. Please state what parts of the code you are having issues with.
ASKER
I have problem with lboSource. What I am trying to do is to clear it from previously loaded data and reload it:
Public Shared Function GetExceptionSourceList()
Dim lst As List(Of NWH_Exception_DataSource) = ExceptionTrackerModel.getFileSourcesFromDB
Dim dsList As List(Of ExceptionTrackerSource)
'Dim flg As New GlobalVariables
'MsgBox("Did I pass global variable value? Here is the anser: " & GlobalVariables.MyGlobalFlag.ToString)
If ExceptionTrackerSource.RIFLAG = True Then
dsList = (From l In lst Where l.SourceID = 11
Select New ExceptionTrackerSource With {
.SourceID = l.SourceID,
.SourceName = l.Source
}).OrderBy(Function(f) f.SourceName).ToList()
Else
'MsgBox("Something went wrong!")
dsList = (From l In lst Where l.SourceID <> 11
Select New ExceptionTrackerSource With {
.SourceID = l.SourceID,
.SourceName = l.Source
}).OrderBy(Function(f) f.SourceName).ToList()
dsList.Insert(0, ExceptionTrackerSource.GetAllSource)
End If
Return dsList
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, Fernando! I was able to clear List Box. I used this Function:
Public Shared Function ClearAllSource() As ExceptionTrackerSource
Dim lst As List(Of NWH_Exception_DataSource) = ExceptionTrackerModel.getFileSourcesFromDB
Dim dsList As List(Of ExceptionTrackerSource) = ExceptionTrackerSource.GetExceptionSourceList
dsList.Clear()
End Function
And I need only one line to call this Function:lboSource.DataContext = ExceptionTrackerSource.ClearAllSource
However when I tried to repopulate the list box using this:
lboSource.DataContext = ExceptionTrackerSource.GetExceptionSourceList
My list box remained empty. I know I am doing something wrong. But what? Would you be so kind to tell me?
Try it this way
lboSource.DataContext = Nothing
lboSource.DataContext = ExceptionTrackerSource.GetExceptionSourceList
ASKER
Still does not work.
ASKER
But this works for some reason:
lboSource.DataContext = ExceptionTrackerSource.ClearAllSource
lboSource.ItemsSource = ExceptionTrackerSource.GetExceptionSourceList
lboSource.DataContext = ExceptionTrackerSource.GetExceptionSourceList
ASKER
Thank you Fernando for pointing me to the right direction. I do appreciate your help.
Not a problem Burzhuin, glad you got it working.👍
If memory serves me correctly you should be able to do this.
Open in new window