avoid inertia scrollviewer for negative offset Windows 8 App - offset

i would like to know how can i remove the inertia effect of the scrollviewer content when the offset is negative.
In reality the offset is 0.0, but the content moves in negative like a spring.
This is a video that show the effect that i'd like to remove:
http://www.youtube.com/watch?v=3kXce-VK--4&feature=youtu.be
The code is very simple:
<ScrollViewer x:Name="CalendarScrollViewer"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Grid.Column="2" Grid.Row="1"
ZoomMode="Disabled"
HorizontalAlignment="Right"
LayoutUpdated="CalendarScrollViewer_LayoutUpdated" >
<Grid>
...
</Grid>
</ScrollViewer>
Thanks.

Have you tried to set ScrollViewer.IsScrollInertiaEnabled="False" ?

Related

Set Button half the window size in .NET Maui

I'd like to set the size of a button in .NET Maui to take up half of the window size, or some other fraction. I want to have some big buttons, and I can not lie. If I was doing this in html/css, I would set the width to 50%. In .NET Maui, I would think that I would set the widthrequest to 50%. There doesn't seem to be a way to do that because .WidthRequest only takes a double. So, I thought I would get the width of the current window. I try
var width = DeviceDisplay.Current.MainDisplayInfo.Width;
That only seems to return a zero when I try this in windows in debug mode. Googling doesn't seem to be much help. Is there a way to set a button to a width?
TIA
Maui has proportional sizing for grid row and columns. You don't explain where you want your button but you can use multiples of * proportional.
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/grid?view=net-maui-7.0
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
If you put a button in that middle row then it will be half the width of the grid and central.
Similarly, define 3 columns with * widths and you have a central cell half the width and half the height of the grid.
I test the code and it work well:
<Button                
x:Name="btn"                
Text="btn"/>
double width= DeviceDisplay.Current.MainDisplayInfo.Width/4;    
public MainPage()
{        
InitializeComponent();        
btn.WidthRequest=width; 
}

Contents of Block Layout Change Position on Zoom

I need to fit a Label and a Hbox within block layout.
<l:BlockLayout id="BlockLayout">
<l:BlockLayoutRow>
<l:BlockLayoutCell width="100%">
<Label
class="sapUiTinyMargin"
text="Hello All"
>
<Hbox>
</Hbox>
</l:BlockLayoutCell>
</l:BlockLayoutRow>
</l:BlockLayout>
Every time I press Ctrl++ / - to zoom in or out, the block layout contents change their position. E.g.: Label shifts right on zoom out and in on zoom in.
What should I do to stop this?
The thing is: BlockLayout is a responsive UI5 element. It is like a flexbox, and it will always try to adjust its elements to "optimize" (so it thinks) the space it has.
I am not fully aware of what you really want to do, but my advice will be to not use BlockLayout and try to place manually (css) your elements (since it looks you don't like the responsiveness of the elements...
Some properties like: justifyContent="SpaceBetween" justifyContent="SpaceArround" alignItems="Center".
Might be useful to you, I'm not sure.

xamarin form: Can the control bind itself?

Let say I have an Image tag inside the xaml and wanted to be in square size.
<Grid HorizontalOptions="Fill">
<Grid.RowDefinitions>
<RowDefinition Height="auto">
</RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image></Image>
<Image></Image>
<Image></Image>
<Image></Image>
</Grid>
A demo code here have 4 image putting them horizontally within the Grid. The width will be equally defined. So I want the height to be the same as the width. Can I bind themselves like this
<Image x:Name="img" BindingContext="{x:Reference img}" WidthRequest="{Binding HeightRequest}" Grid.Column="1" Grid.Row="0">
Unless you specifically set it somewhere else in code, your WidthRequest will be -1, indicating the control does not explicitly state what width it would like to have, but instead relies on the layout system to workout the correct dimensions.
So this binding, while technically correct, will be useless.
You can try binding to the Width property, which is the readonly property which gets updated with the actual dimensions once the control is laid out.
You can also override the appropriate event and assign the required height there.
Keep in mind that a grid row with height="Auto" will cause A LOT of layout calculation to be done. Especially when changing control sizes after they are already in the visual tree.
Your layout runs **will be* slow.
I suggest you work out a better solution. Such as applying a fixed height to the grid row once the layout engine works out what the cell width for that device is.

Javafx Scene Builder Linear Gradient is what

is there any one knows what on earth is the linear gradient?
How Can I use the right panel, especially the four scroll bar, to adjust the fill of the triangle on the left to make the triangle upper half white but down half black?
Is there any document to help train people how to use this? I am really sorry I can not find it.
Thanks in advance!
General info on linear gradients
The linear-gradient documentation is at:
JavaFX CSS reference.
It is a w3c color stop form.
javadoc of how linear gradients work in JavaFX.
Because the linear gradient in JavaFX CSS is the same syntax as w3c CSS, any tutorial on CSS linear gradients returned by google will probably apply to JavaFX CSS.
Feedback email address for JavaFX documentation is: javasedocs_us#oracle.com
Linear Gradients and SceneBuilder
Scene Builder uses FXML to represent linear gradients. It can also use render linear gradients from CSS, though the gradient editor in SceneBuilder works to edit the FXML representation of gradients and not the CSS representation.
Here is a result of loading the following FXML file into SceneBuilder:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import java.lang.*?>
<?import javafx.scene.shape.*?>
<Polygon xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<points>
<Double fx:value="-50.0" />
<Double fx:value="40.0" />
<Double fx:value="50.0" />
<Double fx:value="40.0" />
<Double fx:value="0.0" />
<Double fx:value="-60.0" />
</points>
<fill>
<LinearGradient startX="0.5" startY="0" endX="0.5" endY="1">
<stops>
<Stop color="WHITE" />
<Stop color="BLACK" offset="1.0" />
</stops>
</LinearGradient>
</fill>
</Polygon>
Scroll Bar Settings
The scroll bar settings are marking the proportional co-ordinates of the start and end properties of the linear gradient. These co-ordinates from a directional vector (line) along which colors in the linear gradient change according to the defined stops. The bars work as follows:
left bar: startY
top bar: startX
right bar: endY
bottom bar: endX
For the above fill, it means start at the top center and travel to the bottom center, varying the color from white to black as you go, so it's a straight top to bottom vertical transition.
Discrete Gradients
If you didn't want a smooth gradient, but instead wanted an abrupt one, then add more stops, for example:
<fill>
<LinearGradient endX="0.5" endY="1" startX="0.5" startY="0">
<stops>
<Stop color="WHITE" />
<Stop color="WHITE" offset="0.5"/>
<Stop color="BLACK" offset="0.5" />
<Stop color="BLACK" offset="1.0" />
</stops>
</LinearGradient>
</fill>

Need GWT SplitLayoutPanel to have max size, dragging is very jumpy

Is there a good way to set the max size for a child of a SplitLayoutPanel? Right now I override its onResize method and call a JSNI function to set the right or width style properties of the parent div of the center panel's div, the right panel's div and the splitter panel's div, if the right/east panel is over 400px wide.
I noticed the splitter and the right panel's size don't even follow the mouse cursor and oscillate wildly between about 4/5 and 2/5 as wide as they should be based on where the mouse pointer currently is.
I have debug in eclipse and tried running it without eclipse and it's the same. I am calling super.onResize(), as well.
If I am understanding your problem correctly, you want to have a SplitLayoutPanel to occupy maximum space of the parent element. For this you can use the percentage property of width like,
SplitLayoutPanel slp = new SplitLayoutPanel();
slp.setWidth( "100%" );
And in the next step you want to add child element into the SplitLayoutPanel and it should occupy maximum area. Then set each child width to 100%
Widget child = // Instantiate any type of widget
child.setWidth( "100%" );
slp.add // Use proper add method and add the child to SplitLayoutPanel
I did not understand what did you mean by dragging is very jumpy. Did you mean Splitter size is too small that you cannot find the splitter. If thas the case, you can increase the splitter size by passing it in the constructor like
int splitter_size_in_pixels = 5;
SplitLayoutPanel slp = new SplitLayoutPanel( splitter_size_in_pixels );
I noticed the splitter and the right panel's size don't even follow the mouse cursor and oscillate wildly between about 4/5 and 2/5 as wide as they should be based on where the mouse pointer currently is.
I too saw jerky movement when dragging the splitter. My south pane contained a vertical panel which contained a label and a table. The fix was to set the VerticalPanel height="100%" . I have appended the uibinder code.
HTH
Julian
<g:SplitLayoutPanel styleName="gwt-SplitLayoutPanelTtc" ui:field="splitLayoutPanel">
<g:north size="40">
...
</g:north>
<g:west size="200">
...
</g:west>
<g:south size="500">
<g:VerticalPanel height="100%" width="100%">
<g:Label ui:field="tableTitle" styleName="tableTitle"></g:Label>
<g:Grid ui:field="table" styleName="gwt-Grid"></g:Grid>
</g:VerticalPanel>
</g:south>
<g:center>
...
</g:center>
</g:SplitLayoutPanel>
You can fix the jerky/jumpy movements by adding intermediate ResizeLayoutPanels.
MyComposite.ui.xml :
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:my="urn:import:my.custom.package.client">
<g:SplitLayoutPanel ui:field="splitLayoutPanel">
<g:west size="250">
<g:ResizeLayoutPanel ui:field="leftMenuOuterPanel">
<my:MenuWidget ui:field="menuWidget" />
</g:ResizeLayoutPanel>
</g:west>
<g:center>
<g:ResizeLayoutPanel ui:field="centerOuterPanel">
<my:AwesomeWidget ui:field="centerWidget" />
</g:ResizeLayoutPanel>
</g:center>
</g:SplitLayoutPanel>
</ui:UiBinder>
thanks to OlivierH answer