Read from DataGrid not working - wpf

I have created a simple datagrid to show some values, let the user change them and read back the changed values in the background program. Here is the XAML design file
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="ButAdd" Content="Add Row" HorizontalAlignment="Left" Height="23" Margin="362,34,0,0" VerticalAlignment="Top" Width="77"/>
<TextBox x:Name="TeBoResult" HorizontalAlignment="Left" Height="90" Margin="52,220,0,0" TextWrapping="Wrap" Text="Display the Row 0 colmn 1 changed value here:" VerticalAlignment="Top" Width="322" AcceptsReturn="True" IsManipulationEnabled="True"/>
<Button x:Name="ButRead" Content="Read Row 2" HorizontalAlignment="Left" Height="24" Margin="425,184,0,0" VerticalAlignment="Top" Width="82"/>
<DataGrid x:Name="DaGr" ItemsSource="{Binding}" HorizontalAlignment="Left" Height="133" Margin="10,75,0,0" VerticalAlignment="Top" Width="174" AutoGenerateColumns="False" IsManipulationEnabled="True" EnableColumnVirtualization="True" >
<DataGrid.Columns>
<DataGridTextColumn Header="Text" Binding="{Binding Path=No, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridCheckBoxColumn Header="Check box" Binding="{Binding Path=Sel}"/>
<DataGridComboBoxColumn Header="Combo box" Binding.XmlNamespaceManager="{Binding Path=Drop}"/>
</DataGrid.Columns>
</DataGrid>
<ComboBox x:Name="CoBo_IN" HorizontalAlignment="Left" Height="20" Margin="344,100,0,0" VerticalAlignment="Top" Width="84" Visibility="Visible">
<ComboBoxItem Content="Move" HorizontalAlignment="Left" Width="88"/>
<ComboBoxItem Content="Dock" HorizontalAlignment="Left" Width="88" Selected="ComboBoxItem_Selected"/>
</ComboBox>
</Grid>
And the backgroud vb.net code is here
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Runtime.CompilerServices
Imports DataGrid.datset
Imports System.Windows
Class MainWindow
Public Property coll As New ObservableCollection(Of bind)()
Private Sub ButAdd_Click(sender As Object, e As RoutedEventArgs) Handles ButAdd.Click
Dim qw As New bind()
qw.No = "Change Me"
qw.Sel = Nothing
qw.Drop = CoBo_IN
coll.Add(qw)
DaGr.ItemsSource = coll
End Sub
Private Sub ButRead_Click(sender As Object, e As RoutedEventArgs) Handles ButRead.Click
Dim val As String
For Each item As bind In DaGr.Items
val = item.No
TeBoResult.Text = TeBoResult.Text & val
Next
End Sub
End Class
Public Class datset : Implements INotifyPropertyChanged
Public Event PropertyChanged As PropertyChangedEventHandler _
Implements INotifyPropertyChanged.PropertyChanged
Private Sub NotifyPropertyChanged(<CallerMemberName()> Optional ByVal propertyName As String = Nothing)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub
Public Structure bind
Public Property No As String
Public Property Sel As Boolean
Public Property Drop As ComboBox
End Structure
End Class
So When I click on the Add Row button the row with the default contents gets added in the TextColumn and CheckBoxColumn but the ComboBoxColumn dosent display the combo!!(but when I double click inside this cell the ComboBox appears but It is empty). What could be reason for this behaviour?
Next the user will change the contents inside the TextColumn and it gets changed in the GUI as required.
Next when the user clicks on the botton Read Row, all the contents of the TextColumn are read one after the other and is displayed in the Result text box. The problem is though the GUI has a new text when it is read sequentially the val variable still shows the previously bound values only. I thought the problem is with TwoWay binding but it seems to be something else.
Why does the read on DataGrid dosen't give an updated value?

I doesn't know to much of VB, but I can see some things here are not ok. For instance ItemsSource="{Binding}". Here you must to reference the collection to bind, in this case coll. The code should be something like this:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
x:Name="window">
<Grid>
<Button x:Name="ButAdd" Content="Add Row" HorizontalAlignment="Left" Height="23" Margin="362,34,0,0" VerticalAlignment="Top" Width="77"/>
<TextBox x:Name="TeBoResult" HorizontalAlignment="Left" Height="90" Margin="52,220,0,0" TextWrapping="Wrap" Text="Display the Row 0 colmn 1 changed value here:" VerticalAlignment="Top" Width="322" AcceptsReturn="True" IsManipulationEnabled="True"/>
<Button x:Name="ButRead" Content="Read Row 2" HorizontalAlignment="Left" Height="24" Margin="425,184,0,0" VerticalAlignment="Top" Width="82"/>
<DataGrid x:Name="DaGr" ItemsSource="{Binding col, ElementName =window}" HorizontalAlignment="Left" Height="133" Margin="10,75,0,0" VerticalAlignment="Top" Width="174" AutoGenerateColumns="False" IsManipulationEnabled="True" EnableColumnVirtualization="True" >
<DataGrid.Columns>
<DataGridTextColumn Header="Text" Binding="{Binding Path=No, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridCheckBoxColumn Header="Check box" Binding="{Binding Path=Sel, Mode=TwoWay}"/>
<DataGridComboBoxColumn Header="Combo box" Binding.XmlNamespaceManager="{Binding Path=Drop, Mode=TwoWay"/>
</DataGrid.Columns>
</DataGrid>
<ComboBox x:Name="CoBo_IN" HorizontalAlignment="Left" Height="20" Margin="344,100,0,0" VerticalAlignment="Top" Width="84" Visibility="Visible">
<ComboBoxItem Content="Move" HorizontalAlignment="Left" Width="88"/>
<ComboBoxItem Content="Dock" HorizontalAlignment="Left" Width="88" Selected="ComboBoxItem_Selected"/>
</ComboBox>
</Grid>
Note the items source binding, and the name of the window, also note the bindings should be two way, for update the source too. This new binding references to the col collection. Now in he code behind you shoul not re-set the grid intems source each time you add an item. If the collection is an observable collection then it is added automatically, and now the items should works::
Private Sub ButAdd_Click(sender As Object, e As RoutedEventArgs) Handles ButAdd.Click
Dim qw As New bind()
qw.No = "Change Me"
qw.Sel = Nothing
qw.Drop = CoBo_IN
coll.Add(qw)
End Sub

Related

WPF- TabControl. how to get DataTemplate key

I have created a TabControl whose tabs are bound to UserControls
<Window x:Class="_MainWindow"...>
....
<TabControl ItemContainerStyle="{StaticResource TabItemStyleVM}" x:Name="tc" Margin="1" SelectedIndex="0" Height="545"
ItemsSource="{Binding Path=TabItems}"
SelectedItem="{Binding Path=SelectedTabItem}"
IsSynchronizedWithCurrentItem="True">
<TabControl.Resources>
<DataTemplate x:Key="0">
<my:myUsrControl0 x:Name="myUsrControl0" DataContext="{Binding ....}"/>
</DataTemplate>
<DataTemplate x:Key="1">
<my:myUsrControl1 x:Name="myUsrControl1" DataContext="{Binding ...}"/>
</DataTemplate>
<DataTemplate x:Key="2">
<my:myUsrControl2 x:Name="myUsrControl1" DataContext="{Binding ...}"/>
</DataTemplate>
...
</TabControl.Resources>
</TabControl>
....
In Window CodeBehind, Im able to change TabControl content dinamically, depending on Tc SelectedIndex
Public Class _MainWindow
Private Sub _MainWindow_Loaded(ByVal sender As System.Object, ByVal e As RoutedEventArgs) Handles Me.Loaded
...
End Sub
Private Sub tc_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Handles tc.SelectionChanged
If Not IsNothing(CType(sender, TabControl)) Then
CType(sender, TabControl).ContentTemplate = TryCast(sender.FindResource(CType(sender, TabControl).SelectedIndex().ToString), Object)
...
End If
End Sub
...
End Class
Now, I should place a new tab between two existing ones (eg: between tabs "1" and "2"). So, I rearranged TabControl like this
<TabControl ItemContainerStyle="{StaticResource TabItemStyleVM}" x:Name="tc" Margin="1" SelectedIndex="0" Height="545"
ItemsSource="{Binding Path=TabItems}"
SelectedItem="{Binding Path=SelectedTabItem}"
IsSynchronizedWithCurrentItem="True">
<TabControl.Resources>
<DataTemplate x:Key="0">
<my:myUsrControl0 x:Name="myUsrControl0" DataContext="{Binding ....}"/>
</DataTemplate>
<DataTemplate x:Key="1">
<my:myUsrControl1 x:Name="myUsrControl1" DataContext="{Binding ...}"/>
</DataTemplate>
<DataTemplate x:Key="10"> <----------- NEW TAB
<my:myUsrControl10 x:Name="myUsrControl10" DataContext="{Binding ...}"/>
</DataTemplate>
<DataTemplate x:Key="2">
<my:myUsrControl2 x:Name="myUsrControl2" DataContext="{Binding ...}"/>
</DataTemplate>
...
</TabControl.Resources>
</TabControl>
at runtime, when I click on new Tab Item "10", the tc_selectionChanged detects tc.SelectedIndex = 2, and fills TabControl content to the UserControl bound to it (ie: myUsrControl2).
I wish to manage TC content upon selected DataTemplate key: how can I get it?

WPF vb.net Apply different button to rows in datagrid

I am creating a column in my DataGrid with
<DataGridTextColumn Header="Deploy" Binding="{Binding Deploy}" Width="100" IsReadOnly="True" CanUserSort="False"/>
In my code, I am adding rows to the columns in my grid using
Public Structure MyRow
Public Property Deploy As String
End Structure
MyGrid.Items.Add(New MyRow With {.Deploy= "Unlimited"})
What I really want to be doing, is in this Deploy field, I want to display one of two buttons dependent on a value. If I have the value 0, I want to display
<Button Grid.Column="3" Padding="0" Content="A" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />
And if I have the value -1 I want to display
<Button Grid.Column="3" Padding="0" Content="B" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />
Any help as to how would be appreciated! I've tried using a CellTemplateSelector
<Page.Resources>
<DataTemplate x:Key="ATemplate">
<Button Grid.Column="3" Padding="0" Content="A" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />
</DataTemplate>
<DataTemplate x:Key="BTemplate">
<Button Grid.Column="3" Padding="0" Content="B" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />
</DataTemplate>
</Page.Resources>
...
<DataGridTemplateColumn Header="A" Width="60" CanUserSort="False" CellTemplateSelector="{StaticResource ButtonTemplateSelector}" />
...
But then I don't know how I could then apply this template when I am adding a row to the DataGrid
Thanks in advance
Just implement your logic in the ButtonTemplateSelector:
Public Class ButtonTemplateSelector
Inherits DataTemplateSelector
Public Property ATemplate As DataTemplate
Public Property BTemplate As DataTemplate
Public Overrides Function SelectTemplate(item As Object, container As DependencyObject) As DataTemplate
If item IsNot Nothing Then
Dim myRow = CType(item, MyRow)
If myRow.Deploy Is "0" Then
Return ATemplate
Else
Return BTemplate
End If
End If
Return MyBase.SelectTemplate(item, container)
End Function
End Class
XAML:
<DataGridTemplateColumn Header="A" Width="60" CanUserSort="False" >
<DataGridTemplateColumn.CellTemplateSelector>
<local:ButtonTemplateSelector ATemplate="{StaticResource ATemplate}"
BTemplate="{StaticResource BTemplate}" />
</DataGridTemplateColumn.CellTemplateSelector>
</DataGridTemplateColumn>

WPF Hierarchical Treeview: Combined binding of a selfrefering hierarchical and a flat source

Recently, I learned a lot about MVVM / Binding / Entityframework etc. And as I always go for the hard way - I use VB.NET - and have to convert most of the code found from C# to VB.NET ;)
So, what's my Topic:
Complete Titel:
WPF Hierarchical Treeview: Combined binding and templating of an selfrefering hierarchical source and a flat source with EntityFramework 6 and Database First Approach.
DataModel:
Image: https://i.stack.imgur.com/LIb1v.png
Expected Treeview
I have two types of Items:
"Dimensions" are from a selfrefering Source (XELL_DIMENSION) and
hierarchical Items. unknown/open Leveldepth.
"Elements" are from a flat Source (XELL_ELEMENTS) a
Image: https://i.stack.imgur.com/QeFwe.png
Ok here's what I have achieved so far:
Mainwindow Class:
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
Dim elementsContext As New XELLEntities()
Tree.DataContext = elementsContext.XELL_DIMENSION.Include("XELL_ELEMS").ToList()
Tree.ItemsSource = elementsContext.XELL_DIMENSION.Where(Function(y) y.DIMEN_PARENT_ID Is Nothing).ToList()
End Sub
XAML CODE:
<TreeView Name="Tree" HorizontalAlignment="Left" Height="187" Margin="10,10,0,0" VerticalAlignment="Top" Width="415">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local2:XELL_DIMENSION}" ItemsSource="{Binding DIM_ALL_NODE}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DIMEN_ID}"/>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding DIMEN_BEZ_LONG}"/>
<ListBox Name="Listy" ItemsSource="{Binding XELL_ELEMS}" DisplayMemberPath="ELEM_BEZ_LONG" BorderBrush="Transparent" BorderThickness="0"/>
</StackPanel>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
Result:
Question:
So that's the closest I came and I used a Listbox for the Elements - but this
is no solution to me.
- How do I solve my Problem?
I am thankful for any CodeSnipped provided.
Eureka! -SOLVED
I had to use a Converter and a TemplateSelector.
XAML:
<TreeView Name="Tree" HorizontalAlignment="Left" Height="187" Margin="10,10,0,0" VerticalAlignment="Top" Width="415"> <TreeView.Resources>
<local3:LeafDataTemplateSelector x:Key="LeafDataTemplateSelector" />
<HierarchicalDataTemplate DataType="{x:Type local2:XELL_DIMENSION}" ItemTemplateSelector="{StaticResource LeafDataTemplateSelector}">
<HierarchicalDataTemplate.ItemsSource>
<MultiBinding Converter="{StaticResource SimpleFolderConverter}">
<Binding Path="DIM_ALL_NODE" />
<Binding Path="XELL_ELEMS" />
</MultiBinding>
</HierarchicalDataTemplate.ItemsSource>
<StackPanel Orientation="Horizontal">
<Image HorizontalAlignment="Center" Height="20" VerticalAlignment="Center" Width="20" Source="MVVM/VIEW/IMAGES/Nodes.png" Stretch="Uniform" />
<TextBlock Foreground="#FF3399FF" Text="{Binding DIMEN_BEZ_LONG}" FontWeight="Bold"/>
</StackPanel>
</HierarchicalDataTemplate> <HierarchicalDataTemplate x:Key="Dimension" DataType="{x:Type local2:XELL_DIMENSION}" ItemTemplateSelector="{StaticResource LeafDataTemplateSelector}">
<HierarchicalDataTemplate.ItemsSource>
<MultiBinding Converter="{StaticResource SimpleFolderConverter}">
<Binding Path="XELL_ELEMS" />
<Binding Path="DIM_ALL_NODE" />
</MultiBinding>
</HierarchicalDataTemplate.ItemsSource>
<StackPanel Height="25" Orientation="Horizontal" ToolTip="Installation File">
<Image HorizontalAlignment="Center" Height="20" VerticalAlignment="Center" Width="20" Source="MVVM/VIEW/IMAGES/Nodes.png" Stretch="Uniform" />
<TextBlock Foreground="#FF3399FF" Text="{Binding DIMEN_BEZ_LONG}" FontWeight="Bold"/>
</StackPanel>
</HierarchicalDataTemplate> <DataTemplate x:Key="Element" DataType="{x:Type local2:XELL_ELEMENT}">
<StackPanel Height="25" Orientation="Horizontal" ToolTip="Installation File">
<Image HorizontalAlignment="Center" Height="20" VerticalAlignment="Center" Width="20" Source="MVVM/VIEW/IMAGES/Shape57.png" Stretch="Uniform" />
<TextBlock Foreground="DarkGray" Text="{Binding ELEM_BEZ_LONG}" FontWeight="Normal" FontStyle="Italic"/>
</StackPanel>
</DataTemplate>
</TreeView.Resources>
</TreeView>
VB.NET - MainWindow
Public Sub New()
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
Dim elementsContext As New XELLEntities()
Tree.DataContext = elementsContext.XELL_DIMENSION.Include("XELL_ELEMS").ToList()
Tree.ItemsSource = elementsContext.XELL_DIMENSION.Where(Function(y) y.DIMEN_PARENT_ID Is Nothing).ToList()
End Sub
VB.NET TemplateSelection
Public Class LeafDataTemplateSelector
Inherits DataTemplateSelector
Public Overrides Function SelectTemplate(item As Object, container As DependencyObject) As DataTemplate
Dim element As FrameworkElement = TryCast(container, FrameworkElement)
If element IsNot Nothing AndAlso item IsNot Nothing Then
If TypeOf item Is XELL_DIMENSION Then
Return TryCast(element.FindResource("Dimension"), DataTemplate)
ElseIf TypeOf item Is XELL_ELEMENT Then
Return TryCast(element.FindResource("Element"), DataTemplate)
End If
End If
Return Nothing
End Function
End Class
VB.NET Hierarchy Converter
Class HierarchyConverter : Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim node = TryCast(value, Employee)
If node IsNot Nothing Then
Return node.Subordinates.Where(Function(i) i.ManagerID = node.EmployeeID).ToList()
Else
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotSupportedException
End Function End Class
Hope this helps somebody ;)

TextBox MouseDown Event within UserControl

I have a user control that contains a TextBox and I would like to capture the mousedown event however, I cannot seem to get things to work! My existing, non working code is below, any assistance would be greatly appreciated.
UserControl xaml:
<UserControl x:Class="LeftLabel"
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"
mc:Ignorable="d" Width="auto" Height="auto" >
<StackPanel DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=TextBlockText}"
Name="UcTextBlock"
Width="{Binding Path=TextBlockWidth}"
FontSize="{Binding Path=TextBlockFontSize}"
HorizontalAlignment="Right"
TextAlignment="Right"
VerticalAlignment="Center"
Margin="5,0,0,0" />
<TextBox Text="{Binding Path=TextBoxText}"
Name="UcTextBox"
MouseDown="UcTextBox_MouseDown"
Width="{Binding Path=TextBoxWidth}"
Height="{Binding Path=TextBoxHeight}"
FontSize="{Binding Path=TextBoxFontSize}"
Padding="{Binding Path=TextBoxPadding}"
Margin="5,0,0,0"
BorderThickness="0" />
</StackPanel>
</StackPanel>
</UserControl>
UserControl.vb:
Public Event TextBoxMouseDown As EventHandler
Private Sub UcTextBox_MouseDown(sender As Object, e As MouseButtonEventArgs) Handles UcTextBox.MouseDown
RaiseEvent TextBoxMouseDown(sender, e)
End Sub
For testing purposes I am adding the UserControls to my MainWindow programmatically:
Dim count As Integer = 1
While count < 10
Dim ucl As New LeftLabel
With ucl
.Margin = New Thickness(4)
.TextBlockText = "Label " & count.ToString
.TextBlockWidth = 100
.TextBlockFontSize = 12
.TextBoxFontSize = 12
.TextBoxHeight = 20
.TextBoxText = "Initial Text " & count.ToString
.TextBoxPadding = New Thickness(2)
.TextBoxWidth = 150
AddHandler .TextBoxMouseDown, AddressOf LabelLeftTextBoxMouseDown
End With
TextBoxStackPanel.Children.Add(ucl)
count += 1
End While
Private Sub LabelLeftTextBoxMouseDown(sender As Object, e As EventArgs)
Dim txt As TextBox = DirectCast(sender, TextBox)
MsgBox(txt.Text)
End Sub
This is a somewhat common problem.
It occurs with some controls due to the fact that these controls handle these events internally. The button, for instance, "swallows" the click and rather exposes its own event - the Click-event.
If you want to declare your textbox-event-handlers in XAML, I suggest you checkout the Preview*-events (i.e. PreviewMouseDown), these always occur, maybe that can solve your problem if you need to react to clicks.
<TextBox Text="{Binding Path=TextBoxText}"
Name="UcTextBox"
PreviewMouseDown="UcTextBox_PreviewMouseDown"
Width="{Binding Path=TextBoxWidth}"
Height="{Binding Path=TextBoxHeight}"
FontSize="{Binding Path=TextBoxFontSize}"
Padding="{Binding Path=TextBoxPadding}"
Margin="5,0,0,0"
BorderThickness="0" />

How to use UpdateSourceTrigger=Explicit in an Items control like ListBox etc

I have a ListBox that each of its items has a button, I set all the textboxes in the dataitem that the Binding.UpdateSourceTrigger is Explicit.
I added a handler to the button's click, now what?
How do I collect the info from the controls? they don't have a key they are dynamic, how do I get their BindingExpressions?
<ListBox ItemsSource="{Binding Path=Phones}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type data:Phone}">
<StackPanel Style="{StaticResource StackPanelStyle}">
<TextBox Margin="5" VerticalAlignment="Center" Name="tbNumber"
Text="{Binding Number, ValidatesOnExceptions=True, UpdateSourceTrigger=Explicit}"
/>
<Button Click="btnSavePhone_Click" Margin="5"
Content="_Update" IsEnabled="{Binding IsValid}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Private Sub btnSavePhone_Click(sender As Button, e As RoutedEventArgs)
'As I only have one TextBox I can use the following filter,
'you can of corse change it to Where c.Name = "tbNumber"
Dim tbNumber = From c As FrameworkElement In _
DirectCast(sender.Parent, StackPanel).Children Where TypeOf c Is TextBox
Dim x = tbNumber.ToList
Dim be = tbNumber.Cast(Of TextBox).First _
.GetBindingExpression(TextBox.TextProperty)
If Not be.HasError Then be.UpdateSource()
End Sub
Update
In some scenarios, BindingGroup would be the best solution, then U call BindingGroup.UpdateSources.

Resources