|
Hello All,
I have came across below mentioned error message. I dont know why such types issue happens.Anyone can tell me why this issue happens...
Runtime Error 4008... Layout Cycle Detected... Layout Could Not Complete.
Thanks
|
|
|
|
|
This means that you have put too many user controls on the page for the render cycle to complete. It has been upper bounded so that "pathological" (thanks to Microsoft's Rob Relyea for using this term) bounds don't come into play. Basically, the layout has been bounded so that the layout cycle doesn't complete because the layout size is changing.
Rob Relyea has this to say (citing textboxes as an example):
"Layout uses while loops, and the loops need some sort of upper bound on them so that they don’t loop forever in pathological conditions. An example of a pathological condition is if foo’s size is changed in the foo.SizeChanged event handler. There are a number of ways that a layout loop counter can be “used up” legitimately, such as doing anything to invalidate measure during an arrange call, invalidating measure or arrange during a SizeChanged or LayoutUpdated handler (even if a pathological condition is avoided), etc. The TextBox control is doing something to “use up” a layout loop iteration. Since the layout cycle detection is triggered at 250 iterations, under ideal circumstances, you can measure/arrange at most ~250 TextBoxes at once. It has nothing to do with frame rate, the hardware, the browser, etc. It also doesn’t matter how many TextBoxes you have in total, just how many you are laying out in one frame. This is most critical at startup time, when if you have > 250 visible TextBoxes in the tree, you will get a layout cycle. You will also have problems any other time you add > 250 visible TextBoxes, or if you have somehow incrementally added TextBoxes in groups so that you have gotten away with having more than 250, but all TextBoxes layout has been invalidated at once, such as by resizing the browser. You can have as many collapsed TextBoxes on the screen as you want—layout just skips over collapsed controls. Also, if you add the TextBoxes incrementally, and somehow manage them so that they won’t all get invalidated at once (e.g. by putting them in parent containers that won’t ever be resized) you should be OK."
|
|
|
|
|
My goal is to have a *reusable* TreeView control (lets call it MyTreeView) that fills in all the missing pieces of the current WPF TreeView. That is, I want to have out of the box support for images, checkboxes, node lines, etc. When I first started learning WPF, I wrote a MyTreeView control that does exactly this, so I know how to accomplish all that stuff... however, since I was just learning WPF at the time, it wasn't written very well and broke a lot of WPF functionality that I now fully undertand . So its time to rewrite it.
My issue is kind of which way to go with the core design. I know I don't want to give up the HierachialDataTemplate functionality (which I kind of did with v1), but I also know that I would ideally like to rely on the developer for how to get the data ONLY. I do not want the developer to have to deal with setting up the VisualTree. Thats my job.
I always see the HierachialDataTemplates set up like this:
<HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Value}">
<TextBlock Text="{Binding Key}" />
</HierarchicalDataTemplate>
That does populate the tree and I would like to keep that functionality, but I'd like to do something where instead of specifying a TextBlock like everybody does, I'd like to have something along the lines of:
<HierarchicalDataTemplate x:Key="TreeViewItemTemplate" ItemsSource="{Binding Value}">
<ItemTextBinding="{Binding Key}" ItemImageBinding="{Binding ImageSource}" ItemIsCheckedBinding="{Binding IsChecked}" />
</HierarchicalDataTemplate>
Doesn't have to be that exact syntax, but you get the idea... instead of specifying the VisualTree, I want to specify how the various UI elements should be data binded (or bound?).
Some issues that I haven't figured out:
1) I can't have attached properties on HierarchicalDataTemplate, so I'd probably have to derive a new class called TreeViewDataTemplate or whatever and force the developer to use that?
2) Doesn't seem possible to set properties on TreeViewItem from within the HierarchicalDataTemplate?
3) the highlight / focus rectangle covers everything in the HierarchicalDataTemplate VisualTree, fine for Vista / Win7 since thats the style, but on XP, thats not the style... the image and checkbox is not included in the highlight rectangle.
If #2 is not possible in anyway, it seems like this idea is kind of dead in the water... I did a similiar thing for ListView, but that had a clean place where the containers are created and I could easily hook into and set up all the data binding... doesn't seem to be the case here.
|
|
|
|
|
Hello,
I have a converted SVG to XAML (by Inkscape). It looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2996" Width="42" Height="544">
<Canvas.RenderTransform>
<TranslateTransform X="28.0625" Y=" -217.5"/>
</Canvas.RenderTransform>
<Path Name="path126" Fill="Black" Data="m 10.03125 218.53125 c -1.6395929 0.0966 -3.3798805 1.83194 -6.34375 6.09375 -5.9949892 7.93715 -14.595317 26.52565 -18.03125 36.21875 -5.152605 20.33505 -6.842535 45.06395 -5.125 68.9375 0.841522 7.92825 2.532316 25.58259 5.125 39.71875 4.277456 33.60207 5.15625 47.73889 5.15625 61.875 -0.876011 22.96895 -6.848809 41.50368 -16.3125 53.875 -1.718393 1.76478 -2.5625 3.53295 -2.5625 4.4375 0 0.90455 0.844107 2.67273 2.5625 4.4375 9.463691 12.37132 15.436489 30.89127 16.3125 53 0 14.99638 -0.878794 29.11498 -5.15625 61.8125 -2.592684 15.0407 -4.283478 32.71323 -5.125 39.78125 -1.717535 24.73379 -0.02761 49.47575 5.125 68.90625 4.277456 15.90088 19.751417 43.3125 24.0625 43.3125 1.717534 0 3.4375 -1.78887 3.4375 -3.5625 0 -0.89571 -1.719966 -3.51811 -3.4375 -6.1875 -10.30607232 -14.99633 -14.6262161 -30.03104 -16.34375 -53 0 -14.13615 0.8787945 -27.40216 5.15625 -60.96875 C 0.24878379 623.98719 1.968604 608.08279 2.84375 601.875 6.2796825 559.4755 -0.57292742 523.24857 -17.75 496.75 c -2.593549 -3.53846 -4.3125 -7.0625 -4.3125 -7.0625 0 0 1.718951 -3.55525 4.3125 -7.09375 C -0.57292742 456.09522 6.2796825 419.86657 2.84375 376.5625 1.968604 371.25926 0.24878379 355.37724 -1.46875 341.25 -5.7462055 308.5791 -6.625 295.29239 -6.625 281.15625 c 1.7175339 -22.96897 6.03767768 -38.00367 16.34375 -53 3.435068 -5.30329 4.311289 -7.04771 2.59375 -8.8125 -0.810483 -0.55428 -1.535981 -0.85639 -2.28125 -0.8125 z"/>
</Canvas>
As you can see, all path's coorditates are shifted out of the canvas' bounds and then translated back. Is there an easy (automatic) way to translate all paths Data , so the redutant transform could by removed?
EDIT: I have tried to paste it to Calc and use a formula to add transform's parameter, but I realized that Calc cannot distinguish X and Y in path's Data.
Thanks in advance,
Greetings - Jacek
|
|
|
|
|
The Path's data ends up being a StreamGeometry at runtime and I don't see a direct way to get at its data.
You could try something like this (taken from this link[^]):
PathGeometry geometryTransformed = Geometry.Combine(Geometry.Empty, geometry, GeometryCombineMode.Union, transform);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
IMHO it's rather a text processing task. After all, I want to alter the XAML to remove Transform declaration. It seems that I will left it as it is and it end up in a hall of shame some day, xor write a script which will make it.
Greetings - Jacek
|
|
|
|
|
Jacek Gajek wrote: IMHO it's rather a text processing task.
At design time, yes. I thought you wanted a runtime way to do it, sorry
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I have a four combo boxes, along with one text box and all 5 controls. The principle is that if the user selects an item from the first combo box, this selected item then gets reflected in the text box and the four other combo boxes. Whilst this action is working, if the user then selects a new item from the first combo box, say the next item down in the list, the new item is not showing in the other controls. The previous item is still there and hasn't been refreshed. Checking the class object, when first used, the object is being set with the value, but when selecting a new value from the combo box, this new value is not being passed on or up dates the object. I am using INotifyPropertyChanged!
I have set IsSyncronizeWithCurrentItem ="true" on all of the combo boxes, but this isn't working.
How do you very simply, keep all these controls in sync? Code is being built using MVVM design pattern.
modified on Monday, June 27, 2011 3:53 PM
|
|
|
|
|
IsSynchronizedWithCurrentItem does work. I've used it myself. I won't ask why you have 4 ComboBoxes and a TextBox all showing the same exact info , but if its not working, you're likely doing something wrong, so post your code.
|
|
|
|
|
Check that the binding of the selecteditem in the combobox is Mode="TwoWay" .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello guys... I am new to Silverlight. I am trying to create child windows in silverlight but when I try to access some of the methods shown online, those methods are not shows in intellisense. For example
namespace SampleGUIs
{
public partial class MainPage : UserControl
{
private ChildWindow cw;
public MainPage()
{
InitializeComponent();
cw = new ChildWindow();
cw.Closed += new EventHandler(ShowMessage);
}
}
}
I have included System.Windows and System.Windows.Control. Same is the case in ChildWindow.xaml. Some of the methods are not shown like
namespace SilverlightApplication9
{
public partial class PopupWindow : ChildWindow
{
public PopupWindow()
{
InitializeComponent();
this.Title = "Child Window";
}
}
}
what can be the problem? thnx
modified on Monday, June 27, 2011 7:15 AM
|
|
|
|
|
Seems rather obvious, ChildWindow does not have a Title Property whereas UserControl does. It all comes down to what you are deriving your view from.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanx for your answer. It certainly has Title property. I have just solved it. May be I was putting the code in wrong places. But now its working.
|
|
|
|
|
Hi All !
I using DataGrid in WPF and Using DataGrid.RowDetailsTemplate but i only click 1 row .How do I can click more that row in DataGrid?
You can Help me?
Thanks
|
|
|
|
|
There should me a SelectionMode (I think) that can be set to extended.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Using :
<dg:DataGrid AutoGenerateColumns="False"
SelectionMode="Extended"
ItemsSource="{Binding Source={StaticResource FlickrFeed}}"
RowDetailsVisibilityMode="VisibleWhenSelected">
<dg:DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5">
<Image Source="{Binding XPath=media:thumbnail/@url}"
Width="60" Height="60"/>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Foreground="CadetBlue" FontSize="20"
Width="400" TextWrapping="Wrap"
Text="{Binding XPath=media:category}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</dg:DataGrid.RowDetailsTemplate>
but only click a row.i want click more that row.
can you hepl me?
<dg:DataGrid.Columns>
<dg:DataGridTextColumn Header="Title"
Binding="{Binding XPath=title}" Width="150"/>
<dg:DataGridTextColumn Header="Published"
Binding="{Binding XPath=pubDate}"/>
<dg:DataGridTextColumn Header="Author"
Binding="{Binding XPath=media:credit}" Width="*"/>
</dg:DataGrid.Columns>
</dg:DataGrid>
</Grid>
|
|
|
|
|
tâzn wrote: but only click a row.i want click more that row.
hold the <shift> or <ctrl> key when you click the second row
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
lets say I have something like this in XAML:
<GridViewColumnCollection x:Key="Foo">
<GridViewColumn ... />
<GridViewColumn ... />
<GridViewColumn ... />
</GridViewColumnCollection>
if I do FindResource("Foo"), I get a GridViewColumnCollection, no problemo.
However, I'm using docking windows, and in a lot of situations, multiple windows share the same exact instance of MyUserCtrl.xaml and so they share the same exact instance of GridViewColumnCollection. This happens if I open multiple windows of the same type. Its a VisualTree optimization in docking windows.
So what happens is that if I resize a column in MyUserCtrl(instance 1), those values are shared across to MyUserCtrl(instance 2).
I could declare the GridViewColumns in code, but setting up all the properties, bindings, etc. is a PITA.
Is there a way to say "give me a new instance of Foo?
GridViewColumnCollection unfortunately does not implement IClonable. GridViewColumnCollection and GridViewColumn are not serializable either, so I can't do that trick.
Doing a member wise copy seems like another PITA.
Surely there has to be a clever way to keep those columns defined in XAML and be able to copy them or get new instances?
|
|
|
|
|
Seems like it works if I break GridViewColumnCollection out into a seperate ResourceDictionary and just create new instances of that ResourceDictionary. Seems kinda cheezy though. If you have a better way, let me know.
|
|
|
|
|
You could use XamlReader[^] perhaps.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hmm... looked good on paper , but it wouldn't serialize my collection (of MyGridViewColumn : GridViewColumn items), because the class has some private members that aren't serializable. I tried marking them as NonSerialized, but XamlWriter still had a hissy fit.
|
|
|
|
|
Oh, I don't believe I saw the "My"s in your original post
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Lol, this thing is fighting me every step of the way.
I thought I got it to work by breaking that GridViewColumnCollection out into a seperate ResourceDictionary and creating multiple instances of the ResourceDictionary... I do get new instances of the columns...
BUT...
1) GridView.Columns is not a DP and you can't bind to it...
2) You can't add a GridViewColumn to more then one GridViewColumnCollection or it throws an exception
So I have to copy the columns into an ObservableCollection<GridViewColumn>, then clear the original GridViewColumnCollection then add a DP to MyGridView that can be binded to.
I thought WPF & MVVM was supposed to simplify things
|
|
|
|
|
You can actually use classes like MemoryStream and BinaryFormatter to serialize this data. This would be cloning your initial object and making a copy of it.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I am new to WPF, but I would like to know if someone can show me how to delete a row in one datagrid based upon a selection from another. The application uses C# and MVVM design pattern. Can anyone help?
Thanks
|
|
|
|