|
Hi,
my question is, how do I sort related items of an entity.
In an invoice editing window, I have one ComboBox displaying all customers:
XAML:
<UserControl.Resources>
<CollectionViewSource x:Key="cvsCustomers"
d:DesignSource="{d:DesignInstance local:Customer, CreateList=True}" />
...
</UserControl.Resources>
<ComboBox ItemsSource="{Binding Source={StaticResource cvsCustomers}}" .../>
Code-behind:
Dim cvsCustomers As System.Windows.Data.CollectionViewSource
cvsCustomers = CType(Me.FindResource("cvsCustomers"), System.Windows.Data.CollectionViewSource)
Dim qryCustomers = _
From c In myEntities.Customers _
Order By c.CustomerCode
Select c
cvsCustomers.Source = qryCustomers
Now I have a 2nd ComboBox displaying all contact persons of the selected customer. This works fine, but the entries in this second ComboBox are unsorted / sorted by ID.
XAML:
<ComboBox ItemsSource="{Binding Path=myInvoice.Customer.Contacts}" .../> ;
How do I get the list on the 2nd ComboBox sorted?
King regards,
and thanks in advance for tips/suggestions,
Nico
|
|
|
|
|
Hey,
I've been optimising a piece of software with a very large number of simple controls (~30000), most of whom have their parent panel virtualised at any one time (reducing the number in the visual tree to a few hundred). Running through ANTS profiler, I'm told that 60-70% of CPU-time is taken up by UIElement_CreateAutomationPeerDelegate.Invoke and its child methods. A user interacting with the program for 20 seconds or so [creating an additional ~20 of these controls, deleting a few, and moving a few around the page] results in this method being called 5.4 million times. Putting a counter near this method confirms this when run without debugging/ANTS.
As far as I'm aware, I haven't touched AutomationPeer-related methods, and it is used for Accessibility/COM stuff. Can I turn this 'function' off, or are there ways of reducing how many times it is called?
TIA,
Lee
|
|
|
|
|
At the risk of getting 1'ed, I'd say you are trying to band aid things here. Fix the real issue. You shouldn't need 30,000 controls in a single window .
-- Modified Monday, July 18, 2011 7:04 PM
|
|
|
|
|
Haha, well agreed to an extent. The maximum number of controls 'on' the window at any one time is actually around 200 (and usually only around 40) - the rest are held in memory waiting to be connected to the visual tree when scrolling takes place.
I have tried virtualising these 'properly' so that they are re-used but the overhead for them binding to their data is actually more costly than having them just sit in memory (which I certainly found surprising)
|
|
|
|
|
Hi,
is their any timepicker control available in wpf with vb.net?
|
|
|
|
|
|
|
I am looking for a way where a control can be enable when an item from a combo box is selected. Is there a simple way through data binding when a user selects an item from a combo box that it then enables another control to be used?
|
|
|
|
|
One way is to bind IsEnabled on the control(s) to the ComboBox SelectedIndex or SelectedItem property using a value converter[^] on the binding to convert the Selectedxxx value to a bool.
[System.Windows.Data.ValueConversion(typeof(int), typeof(bool))]
public class SelectedIndexToIsEnabledConverter : System.Windows.Data.IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return ((int)value >= 0) ? true : false;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new System.NotImplementedException();
}
}
<UserControl.Resources >
<local:SelectedIndexToIsEnabledConverter x:Key="SelectedIndexToIsEnabledConverter" />
</UserControl.Resources>
...
Example binding:
IsEnabled="{Binding Path=SelectedIndex,ElementName=comboBox1,Converter={StaticResource SelectedIndexToIsEnabledConverter},Mode=OneWay}"
Mark Salsbery
Microsoft MVP - Visual C++
modified on Friday, July 15, 2011 12:33 PM
|
|
|
|
|
Hello,
Could someone help me out here please.. I have a game algorithm problem: http://oi56.tinypic.com/29x6op0.jpg
Thank you
|
|
|
|
|
Please post on the algorithm board[^] if you want algorithms.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Wrong forum.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Not wrong forum. The people from the algorithm forum sent me here.
|
|
|
|
|
And yet you say you have a problem with an algorithm, ergo it's an algorithm forum post.
|
|
|
|
|
A game algorithm in a Silverlight app.
|
|
|
|
|
Hello All,
I have issue with WCF ASYNC call. WCF service give me a random response. Sometimes it gives me result and sometimes not. I have set max values for binding related properties.
Can anyone can help me to figure out this issue?
Thanks
|
|
|
|
|
This could be something to do with the timeout or buffer size.
Try changing these settings.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Hi,
I wouold like to learn a little about how to design better UI in silverlight or WPF in visual studio.
1-
Is there a book to teach me that in visual studio xaml or should I buy a step by step book in expressin blend? I say expression blend because it seems that I can use the code in expression blend and paste the xaml into visual studio.
Thank you
|
|
|
|
|
I don't know a book to recommend, but you don't need to paste code into visual studio. Expression Blend works with Visual Studio solutions/projects so you can edit (and run) code in Blend and edit and debug in Visual Studio as well.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
To learn better design, Expression Blend would be a better bet than Visual Studio.
As already pointed out, you can edit xaml in Expression Blend as well.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Yes "Good Answer". You can use Expression Blend to create the UI styles very easily which is very very difficult if you are using Visual Studio to design. Visual Studio requires depth knowledge on XAML. Also more effort is require if you are designing using the VS. Use Expression Blend which will help you a lot.
Silverlight 5 Tutorials : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
|
|
|
|
|
You're welcome and that's what we're here for - to help!
|
|
|
|
|
Hey all,
I'm running into a problem when binding a property of a GroupItemTemplate (in the WP7 LongListSelector) to a converter I built. I want the converter to check if there are items to be displayed in the group, and according to if there are items, set a Brush to the background.
This is my code for the Converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is Group<TrackInfo>)
{
Group<TrackInfo> group = value as Group<TrackInfo>;
if (group != null)
{
if (group.Items.Count == 0)
return (SolidColorBrush)Application.Current.Resources["PhoneChromeBrush"];
else
return (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
}
}
return new SolidColorBrush(Color.FromArgb(128, 255, 0, 0));
}
And this is in my XAML:
<DataTemplate x:Key="groupItemTemplate">
<Border Width="99" Height="99" Background="{Binding Converter={StaticResource groupItemBackgroundBrush}}" Margin="6" IsHitTestVisible="{Binding HasItems}">
<TextBlock Text="{Binding GroupTitle}"
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="36"
Margin="{StaticResource PhoneTouchTargetOverhang}"
Foreground="{StaticResource PhoneForegroundBrush}"
VerticalAlignment="Bottom"/>
</Border>
</DataTemplate>
<valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />
...
<toolkit:LongListSelector x:Name="lstTracks" Height="800" Width="480" DisplayAllGroups="True"
ListHeaderTemplate="{StaticResource listHeader}"
ListFooterTemplate="{StaticResource listFooter}"
ItemTemplate="{StaticResource itemTemplate}"
GroupHeaderTemplate="{StaticResource groupHeaderTemplate}"
GroupItemTemplate="{StaticResource groupItemTemplate}">
<toolkit:LongListSelector.GroupItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</toolkit:LongListSelector.GroupItemsPanel>
</toolkit:LongListSelector>
I get an Unspecified Error, wich isn't exactly quite helpful... Is there a better way to find out if the group has items and accordingly set a Brush? Or is there an error in my code I don't see?
Thanks for helping,
MadMatt
|
|
|
|