How can I make it after ticking the box and it turns uneditable right away?
This question is somewhat loaded because the answer is, it depends.
Your screenshot makes it look like that control is in a grid row, which would imply the control is connected to a datasource. If that's the case, do you want only the checkbox to be disabled or the entire row?
You would probably put code in the datasource field's modified method or the datasource's active method.
If the checkbox is a standalone control, you would override the clicked method with something like:
public void clicked()
{
super();
if (this.checked())
this.enabled(false);
}
I believe it's due to Field properties in table.
Seems like it restricts edit after creation.
Otherwise - check code on form (or class maintaining the form). It might be on Control/Field/Datasource/Table modify method.
Related
In Xamarin Forms, I have a custom view with a BindableProperty:
public static readonly BindableProperty SelectedItemProperty
= BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(OneOfNButtons), null,
BindingMode.TwoWay);
I use that custom view within a custom page:
<exodus:OneOfNButtons ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab, Mode=TwoWay}"/>
The two-way binding works as expected.
Now I want to trigger an animation that moves the entire OneOfNButtons control up to middle of page, so I can show related content below it, whenever SelectedItem changes. That is, it is not the primary focus of the page, it is down at bottom. If user is interested in it, they click any of the buttons on it, and half the page becomes dedicated to that topic, with the row of buttons acting like tabs, just above the content.
I understand DataTriggers, but those are for specific values. I'm looking for a trigger on any change to SelectedItem property. (If the logic belonged within the custom control itself, I could add code to the SelectedItem setter.)
This is logic specific to the page, so it belongs with the page; is not part of the custom control.
This is logic specific to this UI, so it belongs with the page, not with page's view model.
I've written the question as "invoke a code behind method", because that is the technique I would like to know how to do in general, even if this specific situation could be handled entirely in XAML.
Though I would also be glad to know how to trigger other XAML, on any change.
(If you know a WPF XAML technique, it might work in Xamarin Forms, though XAML here is more limited. Specifically, X-Forms bound properties are not "DependencyProperty"s, so I don't know how to "chain" properties.)
There are a number of XAML & data binding questions on SO, but all the ones I have found either discuss binding between view and model, or within a single view (I need a change in one view to affect the containing view), or involve messaging between the views (the sub-view does not and should not know about this requirement, so messaging isn't applicable), or triggering on specific values, or are for WPF and don't appear to be supported in Xamarin Forms.
You can handle any property changed events with this.
this.YourControl.PropertyChanged += YourControlPropertyChanged;
private void YourControlPropertyChanged(object sender,PropertyChangedEventArgs e)
{
if(e.PropertyName == "SelectedItem")
{
//Code
}
}
Is there any way to do that?
I mean, if the form fullfill specific conditions setVisible true or false to a control in the form? Or if i check a CheckBox, show some specific ComboBox?
Thanks in advance for your help
I would recommend enabling and disabling fields, rather than hiding them.
Open a Supplier, and on the Invoice and Delivery fast tab choose select the Calculate withholding tax CheckBox. This is the VendTable form.
The Calculate withholding tax control will enable and disable a second control depending upon the value selected.
The second control has it's property AutoDeclaration set to Yes, and the event that fires the change can be found on the forms VendTable data source. Find the relevant field (VendTable > Data Sources > Vend Table > Fields > TaxWithholdCalculate) and notice that the modified method has been overridden, changing the control's enabled property. It also has a visible property should you want to remove it from view.
Top Tip: In case that you are not aware, you can right click on any control on a form and choose the Personalise option from the context menu. From there is a form which contains a very useful box called System name. You can find the name of the control/table field from this.
I suggest you this solution for your second problem:
if i check a CheckBox, show some specific ComboBox?
I assume your form is complete (it has all controls needed : comboboxes, checkboxes, etc). And the controls AutoDeclaration-property is set to 'Yes'.
In the AOT expand the Form till you find the CheckBox, expand it as well
Right-click its Methods and select 'Override method' >> 'Clicked'
Finally you can add this code and save/compile the form:
myComboBox.visible(true);
It should look like:
public void clicked()
{
super();
myComboBox.visible(true);
}
For example what if I am trying to hide a custom navigation control what can I place in another webcontrol to conditionally hide the label something like this
<mycontrol:hidethis id=mycontrol1 runat="server">
<mycontrol:mynavi runat="server"/>
</mycontrol:hidethis>
Thanks
Your question is wide open, there could be a few ways to hide your control.
One very simple way to do it is in the PreRender of the navigation control's parent - just set the Visible property of the nav control to false (if the right conditions are met). If coded correctly (i have to say that, sometimes people code stupidly :) then the Visible property will be propagated to all the child controls of the nav control, and none of them will get rendered to the output stream.
Why don't you add a property to the control which says Visible and you internally set the control as visible true/ false.
Have a look at
protected override void AddParsedSubObject(object obj)
{
}
That should be the right place to say wether subcontrols should be rendered or not
I am displaying a combo box in something of a WYSIWYG preview. I want the user to be able to click on the combo box and see the options inside, but I don't want them to be able to change the value. I tried using preventDefault() on the change event but it doesn't work. I don't want to disable it because I do want the user to be able to "look inside" the dropdown.
So I'm trying to block the change, but can't. My next resort is to change the selected index back to what it was before the change, Is there any way to do this within the scope of a ListEvent.CHANGE event listener?
Current Workaround is to basically re-assign the controls selected item the same way I am defining the selected item when I originally build it (a default selection). So a user sees their change then it immediately changes back to the default selection.
Are you sure that a combobox is what you want? could you do the same thing with a list component that is not selectable?
update:
If you must use a combobox and you dont want the lag from listening for the event and resetting the control, I see two possible options. You could subclass the control and make your own. When you do, hijack any methods that set the value besides the initial selection.
Or, you could try something like this: http://wmcai.blog.163.com/blog/static/4802420088945053961/. The site seems like it is in another language but the code is still there. It will allow you to make your options disabled, so the user cannot choose one of the other options.
HTH
I'm new to Flex, although not new to programming. I want to write a generic event handler that will be called by all my textinput boxes when they receive focus. When they have focus, I want to change the colour of the textinput box. When they lose focus, I want to restore the "inactive" color profile. I could write an ActionScript event handler for each textinput box, but we all know that's lame. :o) What I need, then, is a way to access the object which is calling the event handler.
In Delphi, I'd have written a function which passes in the Sender object, allowing me to access the calling object's properties. I'm guessing ActionScript/Flex has a completely different architecture, which is why I'm having difficulty doing this.
Thanks in anticipation!
You should subclass TextInput and handle the focus events in there. I think this would be the simplest way to achieve what you are looking for without having any complex code.
I hope I'm understanding what you're asking for... are you talking about event delegation?
This worked for me:
// 'focusOut' for blur
stage.addEventListener('focusIn', function(e:Event):void {
// The focused control is e.target
});
If you want to change the look of the focused input box, you can do this by setting the focusSkin property. If you want this to happen globally, you can put a style declaration in your CSS file.
In this CSS example I'm replacing the default focusSkin (mx.skins.halo.HaloFocusRect) with an embedded PNG file.
TextInput {
focusSkin: Embed(source="focus.png");
}
TextInput has a few properties for altering the look of the focus, like changing the opacity of the focus skin (focusAlpha property). Check the TextInput documentation for more info.