Note that there are some explanatory texts on larger screens.

plurals
  1. POPart of list not rendered
    primarykey
    data
    text
    <p>I'm having a problem with layout rendering. I have some experience in <code>C#</code> but i never encountered something like this before.</p> <p>I'm building an video messaging application, when a conversation starts an new window is opened and the list and background are set on <code>Collapsed</code>. At the end of an conversation the new window closes and the list and background are set back to Visible.</p> <p>when that happens i get this: <img src="https://i.stack.imgur.com/ww2BY.png" alt="enter image description here"> My list is build with StackPanel and UserControl, when i scroll the list the rendering is fine again.</p> <p>I did some research on Google about objects that aren't rendered on the UI and found that you can use <code>InvalidateVisual</code> to force the UI to be rendered again, but this doesn't seem to be working in my application. I call this method at the end of every conversation, after making the list and background Visible.</p> <p>What are some ways to make sure the UI gets rendered correctly? Thanks.</p> <p><strong>Update 1:</strong></p> <p>I've added this piece of code to my UserControl.</p> <pre><code>protected override void OnRender(DrawingContext drawingContext) { InvalidateVisual(); base.OnRender(drawingContext); } </code></pre> <p>But is this the way to go? I've already seen that method is called over and over in loop when i do it this way, but i doesn't seem to affect the performance on the devices i test on.</p> <p><strong>Update 2:</strong></p> <p>After some more intensive test i found that the code i added in Update 1 does have a great impact on the performance of the application, so this is not going to work for me.</p> <p><strong>Update 3:</strong></p> <p>Now I've created an delay before <code>InvalidateVisual</code> is called, using a <code>Timer</code>. Is set the Timer to 500 milliseconds before calling <code>InvalidateVisual</code>, this forces the layout to render again. By the time my second window is closed the layout will be updated an second time. Here is my code</p> <pre><code>Timer t = new Timer(500); t.AutoReset = false; t.Elapsed += (s, ee) =&gt; { ((Timer)s).Stop(); ((Timer)s).Dispose(); InvalidateVisual(); }; t.Start(); </code></pre> <p>After a quick test it seems to work, but i need to test it more intensely to make sure. Any other suggestions are still welcome.</p> <p><strong>Update 4:</strong></p> <p>After testing my solution in update 3, i found out this is not going to work. @Sheridan: My application doesn't need re sizing, it is an full screen application. This is the code i wrote to create the list:</p> <p>This the XAML code</p> <pre><code>&lt;TabItem x:Name="TabHistory" Header="Geschiedenis"&gt; &lt;sys:FixedScrollViewer VerticalAlignment="Stretch" HorizontalAlignment="Stretch" PanningMode="VerticalOnly" Margin="0,0,0,7" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" HorizontalContentAlignment="Left"&gt; &lt;StackPanel x:Name="CallLogList" /&gt; &lt;/sys:FixedScrollViewer&gt; &lt;/TabItem&gt; </code></pre> <p>And this is the code that fills it.</p> <pre><code>private void OnRosterUpdate(object sender, RosterUpdateEventArgs e) { if (MessageWindow.IsOpen) MessageWindow.Close(); Dispatcher.Invoke((Action)delegate() { if (e.Action == RosterAction.ADD) { RosterContact button = new RosterContact(e.Item); button.Call += StartCall_Callback; button.ShowInfo += Info_Callback; button.HideInfo += button_HideInfo; roster.Children.Add(button); } else if (e.Action == RosterAction.REMOVE) { foreach (RosterContact item in roster.Children) { if (item.UserData.Peer == e.Item.Peer) { roster.Children.Remove(item); break; } } } }); } </code></pre> <p>RosterContact is of type UserControl.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload