C
C#2w ago
Velázquez

ScrollViewer and resizing Canvas problem, please help!!

Hi! I'm developing an application as a final work of one of my subjects at university, whose main purpose is providing an UI in order to keep track of your exercise with some bar graphs and stuff (in the photo). These graphs have to be developed exclusively in WPF, we cannot use extern libraries. However, I find myself in trouble because, as the user can add their own data, the Canvas has to resize dynamically and also has to redraw continuously its own content. This leads us to the main problem, which is that, although I supposedly resize the Canvas, the ScrollViewer that contains the Canvas doesn't, giving an strange functionality to the user in which they have to resize the window in order to see the full graph (and if the window takes the whole screen they wouldn't see anything, just a tiny part of the graph). If anyone could please help me, I have to send this project at night (GMT +1), and I'm trying to achieve a great mark even if I might not succeed. Here's the XAML (i have the scrollviewer disabled due to the problem i have): <ScrollViewer Name="elScrollViewer" Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" Margin="5,5,2,10"> <Canvas Name="elCanvaGraficos" Grid.Column="1" Width="580" SizeChanged="elCanvaGraficos_SizeChanged" Loaded="elCanvaGraficos_Loaded" /> </ScrollViewer> Sorry if this .cs is not as a clear as it should be, I'm Spanish and I've developed the code in my language: if (numFechas > 5 && nuevaEntrada && numFechas != numFechasTotales) double anchuraCanvasNecesaria = elCanvaGraficos.ActualWidth + (numFechas - 4) * espacioFecha * 2; elCanvaGraficos.Width = anchuraCanvasNecesaria; nuevaEntrada = false; numFechasTotales = numFechas; } If more explanations or more code were necessary, please don't hesitate to ask for them. Thank you in advance!
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server