xaml - Silverlight 4 how to detect the screen size and bind to a grid -


I can not get my application to change the screen correctly here My xaml is here < Pre> & lt; Grid X: Name = "Layouts" background = "white" datacentext = "{binding source = {static resource view model}}" minhite = "473" minwyth = "1200" MaxHyct = "600" MaxWide = "1366" & gt; ; & Lt; I: Interaction.Triggers & gt; & Lt; I: EventTrigger EventName = "SizeChanged" & gt; & Lt; Ei: CallMailAction MethodName = "WndSizeChanged" TargetObject = "{Binding}" /> & Lt; / I: EventTrigger & gt; & Lt; / I: Interaction.Triggers & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "300 *" /> & Lt; Column width = "18 9 *" /> & Lt; Column width = "720 *" /> & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; Roadfinion height = "101 *" /> & Lt; RowDefinition Height = "372 *" / & gt; & Lt; /Grid.RowDefinitions> & Lt; Sdk: Data grid grid. Rows = "1" grid. Column = "0" grid. Columnspan = "3" auto-generation column = "false" horizontal alignment = "left" height = "auto" width = "auto" name = "datagroup_columns" vertical element = "top" itemsource = "{binding path = lstdetails} "Row Description SpecialtyNode =" visible "is now selected" IsReadOnly = "True" HeadersVisibility = "All" HorizontalScrollBarVisibility = "Visible" VerticalScrollBarVisibility = "Visible" CanUserReorderColumns = "True" CanUserResizeColumns = "True" CanUserSortColumns = " Truth "& gt; ..... More nested code here ....... & lt; / Sdk: DataGrid & gt;

I have tried to auto-insert user control, and nothing in the grid is working. If I take the minimum minute and maximum, then this page closes on that event I put it there, only after changing it again I would think the fire because it has a user control inside the shell. I use prism I've got an example to find the height and breadth, but it does not work in the beginning. When I bind height and width to double properties, then the incident never starts to fire. I am running out of ideas. I have found ways to put the code behind the actual width and height. I really want to avoid the code behind, but that too was not working. I know that the problem is with the datagrid, because it is dynamic and will increase or decrease depending on the filter. Any help is greatly appreciated. Thank you.

This is the best solution I can come up with. It works, but is probably not right because VM now knows something about the view (correct me if I am wrong), so here is my VM:

  Public Zero WndSizeChanged (Object) Sender, EventArgs e) {this.setHeightWidth (); } Private Zero Sight Width () {this.WindowHeight = (Application. Framework Element as RootVijual). ActiveHight - 125; This.WindowWidth = (Application. Current Framework Element) Reality - 108; } Receive Public Double WindowHigh { Set;} public double window width {get; Set;}   

and in my opinion:

  & lt; Grid X: Name = "Layouts" background = "white" datacentext = "{binding source = {static resource view model}}" height = "{binding path = windowshigh, mode = two}" width = "{binding path = windowwidth , Mode = double} "& gt; & Lt; I: Interaction.Triggers & gt; & Lt; I: EventTrigger EventName = "Layout Upgrade" & gt; & Lt; Ei: CallMailAction MethodName = "WndSizeChanged" TargetObject = "{Binding}" /> & Lt; / I: EventTrigger & gt; & Lt; / I: Interaction.Triggers & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "300 *" /> & Lt; Column width = "18 9 *" /> & Lt; Column width = "720 *" /> & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; Roadfinion height = "101 *" /> & Lt; RowDefinition Height = "372 *" / & gt; & Lt; /Grid.RowDefinitions>   

Actually the event that has been updated has been changed. works like a charm. I'm on the timeline so it has to be done. I hope this will help someone who is in a situation like me. To set H and W at the beginning, do not forget to call setHeightWidth () in Constructor.

Comments