|
Hello,
I'm studying for the WPF exam and playing with the different setting in the GridSplitter control and one of the behaviours makes no sense to me.
Here is the XAML:
<Grid Name="grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="173"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<ListBox Name="listbox1" Grid.Column="0" SelectionChanged="listbox1_SelectionChanged"></ListBox>
<GridSplitter Name="gridsplitter1" Margin="0" Width="5" Grid.Column="1" Grid.RowSpan="2" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
<RichTextBox Grid.Column="2" Name="richtextbox1" />
<TextBox Grid.Column="0" Grid.Row="1"/>
<TextBox Grid.Column="2" Grid.Row="1"/>
</Grid>
When I use the splitter it resizes the previous column (0) but not the next (2), it just trundles across the window not changing size.
I know I can get the desired behaviour by just changing the third column to a proportional size but then it's the proportioning that is changing the column size not the splitter (and I'd get the same result if I put it back the ResizeBehavior to the default "BasedOnAlignment").
What am I missing here? Or is there no point to the PreviousAndNext setting?
Thanks,
Robert.
Robert
|
|
|
|
|
You have an absolute size for the last column. This size will be retained when you attempt the resize, hence the "move". Change it as follows:
<Grid Name="grid1" Width="278">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ListBox Name="listbox1" Grid.Column="0">
</ListBox>
<GridSplitter
Name="gridsplitter1"
Width="5"
Grid.Column="1"
Grid.RowSpan="2"
HorizontalAlignment="Left"
Margin="0"
VerticalAlignment="Stretch"
ResizeBehavior="PreviousAndNext"/>
<RichTextBox Name="richtextbox1" Grid.Column="2"/>
<TextBox Grid.Column="0" Grid.Row="1"/>
<TextBox Grid.Column="2" Grid.Row="1"/>
</Grid>
In order to see the effect, I limited your grid width to 278.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Yes, I know about the using the * for the last column but I have two points of confusion with this.
1) The first column has an absolute size but it has no issue resizing that.
2) If we are going to set the 3rd column width to * we might as well go with the default ResizeBehavior of BasedOnAlignment as we will get exactly the same behaviour - hence why I wonder if PreviousAndNext has any purpose.
(I've explicitly set the ResizeBehavior but could have omitted it as BasedOnAlignment is the default):
<Grid Name="grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<ListBox Name="listbox1" Grid.Column="0" SelectionChanged="listbox1_SelectionChanged"></ListBox>
<GridSplitter Name="gridsplitter1" Margin="0" Width="5" Grid.Column="1" Grid.RowSpan="2" ResizeBehavior="BasedOnAlignment" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
<RichTextBox Grid.Column="2" Name="richtextbox1" />
<TextBox Grid.Column="0" Grid.Row="1"/>
<TextBox Grid.Column="2" Grid.Row="1"/>
</Grid>
Actually even if we use "BasedOnAlignment" but change the 3rd column back to an absolute width and set the HorizontalAlignment to "Right" it still won't resize the 3rd column, it just moves it across again. I can't see why there should be a difference in the behaviour (beyond which column is targeted) between setting the alignment to left or right.
|
|
|
|
|
Have a look at what happens if you add a second splitter. It's a bit of fun:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Name="grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" MinWidth="100"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="173"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ListBox Name="listbox1" Grid.Column="0">
</ListBox>
<GridSplitter
Width="5"
Grid.Column="1"
Grid.RowSpan="2"
HorizontalAlignment="Right"
Margin="0"
VerticalAlignment="Stretch"
ResizeBehavior="PreviousAndNext"/>
<GridSplitter
Width="5"
Grid.Column="3"
Grid.RowSpan="2"
HorizontalAlignment="Right"
Margin="0"
VerticalAlignment="Stretch"
ResizeBehavior="PreviousAndNext"/>
<RichTextBox Grid.Column="2"/>
<RichTextBox Grid.Column="0" Grid.Row="1"/>
<TextBox Grid.Column="2" Grid.Row="1"/>
<RichTextBox Grid.Column="4"/>
<TextBox Grid.Column="4" Grid.Row="1"/>
</Grid>
</Page>
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi All,
I need to create a editable Workflow in run time.
Is is possible?
Please help me with this.
Thanks in advance.
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
Hmm Interesting... Well I would use reflections. Does it need to be a graphical work flow? If so there is a nice WPF Work flow front end here on CP that would work for the graphical front end. I am using it in a 'Visual Power Shell' article...
Here is the link to the work flow designer...
WPF Diagram Designer - Part 2[^]
|
|
|
|
|
for example i want to animate the width of grid from 0 to its Auto Value! i've searched alot but cannot find anything, thanks in advance!
|
|
|
|
|
You will have to apply a resize animation.
Check this out[^].
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Hi everybody.
I'm gonna create a ListView in WPF like below image via XAML and C#
http://xs.to/image-A835_4B3EF7EE.jpg[^]
I've already read some articles like this one[^] , but I'm a little confusing.
Could you please guide me , how I can do it ?
Thanks.
|
|
|
|
|
I am trying to develop a quiz application for the children using WPF and Expression Blend. What actually happens in the quiz is the textblock with the question hovers in the screen for certain time and the children have to click the correct answer of this Multiple choice question. After that certain time the question and the multiple choice answer options has to be updated from the XML data source.
Using the concept of data context I have data bind the XML with the UI but I could not yet dynamically bind to it. Any help would be highly appreciated.
Thank you in advance.
|
|
|
|
|
Take a look into using the Model View ViewModel (MVVM) pattern. There are lots of links on Google about using MVVM in WPF.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
anishshrestha wrote: Using the concept of data context I have data bind the XML with the UI but I could not yet dynamically bind to it.
What do you mean by "dynamically bind to it"?
Programmatically you can create a Binding object, set its properties
as needed, and then set the binding to the property on the element:
Binding binding = new Binding();
binding.XPath = "Name";
myTextBlock.SetBinding(TextBlock.TextProperty, binding);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
For the application, Actually I wish to move to the next question from the XML node as soon as a the time limit is up and so the options for that particular question. I seem to have no idea how to accomplish that in code.
How is it possible to bind the different node of data from the XML, one at a time,for a same control after the certain time gap???
Thank you for the response. I would appreciate any help or suggestions.
Thank you.
|
|
|
|
|
Hi,
In my applcaiton,i make Grid of size Grid Width="1300.441" Height="80",
Its working fien in this resolution.But when i changed my resolution to 1152 width,quater of application get out of the desktop.
How can i avoid that?
I want to display full page in all resolution.
Pls help me
Anu
|
|
|
|
|
Anu_Bala wrote: How can i avoid that?
Don't use hard-coded dimensions.
Instead, use an element that sizes the Grid.
For example, if the Grid is the child of a Window element,
you could set the Window's WindowState to Maximized and the Grid
will fill the Window's client area.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi friends,
I am new to silverlight. I have created a silverlight combo with options 'Male' and 'Female', and included it in an aspx page.
Now I want to know, how to retrieve the selected value and selected text in aspx code.
Please help me.
Shivanandan C V
|
|
|
|
|
Shivan Nandan wrote: how to retrieve the selected value and selected text in aspx code.
aspx code runs on the server and Silverlight runs on the client.
You can use javascript on the client to communicate with a
Silverlight plugin.
HTML Bridge: Interaction Between HTML and Managed Code[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can use javascript. Detailed info can be found at:
http://pietschsoft.com/post/2008/06/Silverlight-and-JavaScript-Interop-Basics.aspx
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 21:45pm.
|
|
|
|
|
Hi,
I have a list of locations, I want to use google map for routing thro' the locations to find the shortest path, get directions and see street view using google API. This a wpf application, I am downloading locations from server.
As far as possible we don't want to use WebBrowser control.
Is there any way to do this? Any help or related link will be greatly appreciated.
Thanks!!
Happy new year
Veena
|
|
|
|
|
|
|
Thanks Mark and Mohammad,
I will study the links.
Veena
|
|
|
|
|
Hey,
I want to make a window with WindowStyle ThreeDBorderWindow transparent. This solution[^] does not work for windows with that WindowStyle
Is this possible, and if so, how?
Cheers!
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
jeroen de dauw wrote: Is this possible, and if so, how?
AllowsTransparency can only be used when the WindowStyle is None.
You could use WindowStyle="None" AllowsTransparency="True" and provide
the titlebar and borders yourself.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey,
I'm aware of that, but don't want to go construct my own titlebar, borders and WindowState buttons myself. The approach would be viable if there was an easy way to get all those things onto my window by using some native properties or so, but I guess that's not possible.
Cheers!
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|