I have a Button defined in XAML that contains a Command including a CommandParameter. The Command binds to the current view's ViewModel, while the CommandParameter binds to another control within the current view. In WPF this would look like:
<TextBox x:Name="MyTextBox" />
<Button Command="{Binding ViewmodelCommand}"
CommandParameter="{Binding ElementName=MyTextBox, Path=Text}" />
According to documentation, in Xamarin.Forms View-to-View binding is possible via changing a control's BindingContext using the x:Reference markup extension:
<Button BindingContext="{x:Reference Name=MyTextBox}"
CommandParameter="{Binding Path=Text}" />
In this case, however, I'm not able to bind the Command to the global Viewmodel! Are there any solutions to this scenario?
Try this:
<Button Command="{Binding ViewmodelCommand}"
CommandParameter="{Binding Source={x:Reference MyTextBox}, Path=Text}" />
Did you solve this?
what I did was to add a binding MyTextBox <-> viewModel like:
MyTextBox.SetBinding(Entry.TextProperty, "PropName");
btn.SetBinding(Button.CommandProperty, "CommandName");
btn.SetBinding(Button.CommandParameterProperty, "PropName");
Related
I'm using NativeScript-Vue to build some app. Trying to figure out how to control the size of my buttons. For instance, i have this code:
<StackLayout orientation="horizontal">
<Button
class="fas"
:text="'fa-upload' | fonticon"
#tap="()=>{backupImage(image)}"
></Button>
<Button
v-if="image.taskStatus==='pending'"
class="far"
:text="'fa-window-close' | fonticon"
#tap="()=>{cancelImageBackup(image)}"
></Button>
</StackLayout>
The result is this:
I would like to remove the large "empty" gray area, on both sides of the icon. I see that native script doesn't support max-width. Tried also padding. How can it be done?
For some reason, works with a StackLayout around it
<StackLayout>
<Button text="LOGIN" class="-rounded-sm bg-primary" width="100dip"></Button>
</StackLayout>
I'm trying to build a table with button on table's header. I'm guiding from here.
This is my code:
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:t="sap.ui.table"
height="100%"
controllerName="xxxxx"
xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="CONFIGURACIÓN DE LA CUENTA" navButtonPress="onCancel" showNavButton="true">
<content>
<f:SimpleForm id="form_requerimiento_datos_generales" minWidth="1024"
maxContainerCols="2" editable="true" layout="ResponsiveGridLayout"
labelSpanL="4" labelSpanM="4"
emptySpanL="0" emptySpanM="0" columnsL="2" columnsM="2"
validateFieldGroup="onValidateFieldGroup">
<f:content>
<core:Title text="Suscripciones"/>
<t:Table
rows="{/Subscriptions?$filter=UserSystem eq '1'}"
selectionMode="None"
visibleRowCount="7">
<t:toolbar>
<content>
<Title id="title" text="Listado de Suscripciones" />
<ToolbarSpacer/>
<Button
icon="sap-icon://add"
tooltip="Agregar Suscripciones"
press="addSuscription"/>
</content>
</t:toolbar>
<t:columns>
<!--columns-->
</t:columns>
</t:Table>
</f:content>
</f:SimpleForm>
</content>
</Page>
</core:View>
I have following error message:
Uncaught Error: failed to load 'sap/m/content.js' from https://sapui5.netweaver.ondemand.com/resources/sap/m/content.js: 0 - NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://sapui5.netweaver.ondemand.com/resources/sap/m/content.js'.
I don't know why I get this error. I think that It's in this part of code:
<t:toolbar>
<content>
<Title id="title" text="Listado de Suscripciones" />
<ToolbarSpacer/>
<Button
icon="sap-icon://add"
tooltip="Agregar Suscripciones"
press="addSuscription"/>
</content>
</t:toolbar>
I don't know why content label is not accepted inside toolbar label (In example this works). When I take off content label of my page. I don't get error messages.
I would like to know what doing for to solve my problem.
Thanks for help me!
UPDATE 1
I solved already my problem but Now I have another problem. I have a problem with CSS of table header (This is overlapped with table body):
The label <t:toolbar> is the aggregation name and it expects a toolbar inside it.
So, ideally <t:toolbar> is followed by a sap.m.Toolbar control.
As to why it is throwing: sap/m/content error is because, it is expecting a control after the <t:toolbar>. Also, since your default namespace is sap.m so it looks for control ( in this case you have specified content) in the default namespace.There is no such control as sap.m.content. Thus, an error.
If you will check your guiding source, you will see they have an <m:Toolbar> after <toolbar> aggregation
Here is the updated code:
<t:toolbar>
<Toolbar>
<content>
<Title id="title" text="Listado de Suscripciones" />
<ToolbarSpacer/>
<Button
icon="sap-icon://add"
tooltip="Agregar Suscripciones"
press="addSuscription"/>
</content>
</Toolbar>
</t:toolbar>
How to add icons to a TextField with NativeScript like you can see on the image: here
My xhtml code:
<StackLayout>
<Image src="res://logo_login" stretch="none" horizontalAlignment="center"></Image>
<TextField #username class="input" hint="GEBRUIKERSNAAM" [(ngModel)]="user.username" autocorrect="false"
autocapitalizationType="none"></TextField>
<TextField #password class="input" hint="PASWOORD" secure="true" [(ngModel)]="user.password"></TextField>
<Button class="btn btn-primary btn-login icon" text="\e912 INLOGGEN" (tap)="login()"></Button>
<button class="btn btn-forgot-pass" text="PASWOORD VERGETEN?" (tap)="forgotpass()"></button>
Check out icon fonts for NativeScript:
https://docs.nativescript.org/ui/icon-fonts
"...
Follow the instructions on the icon font webpage to determine the hex codes of each font glyph, i.e., icon. Add a Label component to your NativeScript app and bind the Label's text property to a one-letter string generated from the character code of the icon you want to show, i.e., String.fromCharCode(0xe903).
..."
I believe this is what you're trying to do.
You can wrap your TextFields in a StackLayout with a horizontal orientation like
<StackLayout orientation="horizontal">
<!--Your password TextField-->
<TextField
#password
class="input"
hint="PASWOORD"
secure="true"
[(ngModel)]="user.password"
></TextField>
<!--You can then place the icon-->
<Label class="fa" text="" (tap)="toggleShow()"></Label>
</StackLayout>
This is a link for a question asked before, which concerns a TreeView:
WPF TreeView: How to style selected items with rounded corners like in Explorer
And this is another link for another question asked too, which concerns a ListView:
WPF ListView: How to style selected items with rounded corners like in Explorer
My question is : How to migrate this Solution on a UniformGrid ? Because I want to have the same effect as shown in the 2 examples, on my UniformGrid Cells.
here is an example of my source code:
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" >
<ItemsControl ItemsSource="{Binding ChildrenList}" BorderThickness="0"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{Binding NumberOfColumns}" HorizontalAlignment=
"Center" Background="Transparent" Margin="4,4,4,4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
You're half-way there already :)
You need to use a ListBox instead of an ItemsControl (because ItemsControl doesn't handle selection and has no such thing as a "selected item").
Then you use the same ItemsPanel as in your example, and the same ItemContainerStyle as in the ListView post you linked to (note: just make sure you rename stuff from "ItemsControl"/"ListView" and "ListViewItem" to "ListBox" and "ListBoxItem"):
<ListBox ItemsSource="{Binding ChildrenList}" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{Binding NumberOfColumns}" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<!-- NOTE: "ListBox" and "ListBoxItem": -->
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
...
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
I have created a custom text box with property "key"(ASP.NET C#).I want to get the value of this property "key" using java script.How can I do this?
Not sure what you are asking.
if you have a textbox rendered like so:
<input type="text" id="foo" key="somekey" text="Hello" />
You could get the value of "key" in JS like so:
document.getElementById('foo').getAttribute('key')
If you are using jquery than for this will help you.
$("#tb1").attr("key")
for this textbox
<input type="text" id="tb1" key="mykey" text="" />