Hi
I work for a company developing Point of Sale applications. We have a control which lists the bill details (quanity / description / price etc). This was initially data-bound but I'm re-writing this as code because the performance improvement
is significant (3-4 times faster).
The Sales Screen includes my control in the WPF as
<my:WPFRegWindow x:Name="RegWindow" Height="240" Width="240" ></my:WPFRegWindow>
It's actual height and width is set at run-time from DB configration when the screen refreshes.
Because POS layouts can change (product buttons added or removed etc.) the till can get a message to redraw.
The problem I'm getting is really weird. If I have 140 lines or less in a order OR the sales screen is active when the refresh happens (through a Dispatcher) then everything refreshes correctly. But, if the sales screen isn't active and I have
141 lines or more in the order, the refresh fails and RegWindow.IsArrangedValid = False. Also, the control is 'disabled' - kinda like it IsEnabled was false. I can't move the scroll bar etc.
A condensed version of the WPF is
<UserControl x:Class="WPFRegWindow"
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"
d:DesignHeight="300" d:DesignWidth="300">
<ScrollViewer x:Name="Scroller"
Width="{Binding Path=Width, ElementName=me}"
Height="{Binding Path=Height, ElementName=me}"
VerticalScrollBarVisibility="Visible"
Background="White"
HorizontalScrollBarVisibility="Disabled"
>
<StackPanel
IsHitTestVisible="True"
Focusable="False">
<ListBox x:Name="ItemList"
VirtualizingStackPanel.IsVirtualizing="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
IsSynchronizedWithCurrentItem="False"
IsEnabled="True"
IsHitTestVisible="True"
BorderBrush="Transparent"
SelectionMode="Multiple"
Focusable="True" >
</ListBox>
</StackPanel>
</ScrollViewer>
</UserControl>
And the code to populate is
Public Class RegWindowItemStackPanel
Inherits StackPanel
Public TIRow As dsTransactionData.tblTransactionItemsRow
End Class
Public Sub ShowTransactionTest(Transaction As clsTransaction)
ItemList.Items.Clear()
If Transaction IsNot Nothing Then
ItemList.Items.Clear()
For Each TIRow In Transaction.TransactionDS.tblTransactionItems
Dim regWindowItem As New RegWindowItemStackPanel With {.TIRow = TIRow}
Dim dock = New System.Windows.Controls.DockPanel With {
.Height = Double.NaN,
.Width = Me.ItemList.ActualWidth,
.LastChildFill = True
}
Dim itemTextBlock = New System.Windows.Controls.TextBlock With {
.Height = Double.NaN,
.Padding = New System.Windows.Thickness(0, 0, 2, 0),
.Text = TIRow.ItemText
}
dock.Children.Add(itemTextBlock)
regWindowItem.Children.Add(dock)
ItemList.Items.Add(regWindowItem)
Next
End If
End Sub
I use a dock panel as the real code has multiple items in the row (a grid is too restrictive for widths).
WPF is still a little voodoo to me so I'm probably doing something - or many things :) - badly, but I just can't get why there is such a definite cut-off point between working and not.
Any guidelines would be very much appreciated for my sanity.
Cheers
Mike