I have a WPF Window that was created dynamically by loading a XAML script, which is part of a bigger script(Proprietary) that we support.
This Script contains supports for user actions like text box lost focus / Check box checked / Button clicked etc..
Say I have a pre written C# class meant to support functionalities of the class.
Since the windows is dynamic it might contain any number of basic UI element like button, radio button check box edit box etc.
How do I link XAML to every possible action on the dialog box, like text box lost focus / Check box checked / Button clicked etc.
Ideally if I can get Name of the UI Element Action and a string from XAML into C# class that is perfect.
example Button1, "Clicked" "Button1_Clicked" here Button1_Clicked is a string that has been passed from XAML which helps me call the function “Button1_Clicked” in my scripting
language. Similarly for a text Box it could be Text1, "LostFocus" "Text1_LostFocus" etc..
How can I write my supporting class and the XAML script to achieve the above mentioned scenario..
just have a look at this post
Loading XAML XML through runtime?
Related
I have an excel-like table. The following picture represents a part of it (for clarification, I setted the text of the inputs to be their respective IDs):
There is a ContextMenu that is fired on right click (code here) in each one of the inputs.
Here is how I find all these input controls at once (I need to use this way because there are some more columns that I do not want to call the ContextMenu):
$('[id^="txtF_"],
[id^="txtP_"],
[id^="txtT_"],
[id^="txtE_"],
[id^="txtM_"]').contextMenu({ ....
This works nice, however, if one of the items is disabled, the browser menu shows up instead. What can I do to fire the custom ContextMenu even if the input control is disabled?
I need to change the Message Box Buttons Ok and Cancel Text to Update and AddNew?
Is it possible in C#.NET or I need to create a form and customize it?
Kindly help me in this.
The MessageBox class does not provide you with option to change the button text. This codeproject article, Localizing System MessageBox allows you do that by simply adding and using the class in your project
It is possible using a MessageBoxManager.dll, which you can get in the following link,
http://www.codeproject.com/Articles/18399/Localizing-System-MessageBox
You cannot change the text in MessageBox Buttons.To implement the scenario you can have your custom message box.Which can be build using User Control and show it as a Dialog whenever needed.
Changing the text of a button on a MessageBox is not possible by default. While the text might be changeable through fake localizations, this does not seem like a good way to do it from my point of view. I encourage creating a separate form.
I have a single line textbox, when I copy some text from lets say notepad that is on multiple lines and paste them in to my text box, only the first line of text appears (thats obvious) but how can I change this so that the lines are joined automatically upon pasting them and separated by a space. I see that I would need to modify the textbox_changed event but this would affect everything that goes on in that textbox not only the paste event. Could you provide me with some code to handle a paste event and ignore all other events.. thanks :)
winforms
mouse paste event
is this what you're looking for?
Clipboard Events
A Textbox in C# has a number of useful events to indicate when certain actions have been taken. For example, .NET textboxes have an event to indicate when the text has changed or when the user has pressed a key. These events allow C# developers to write clean code that interacts with textboxes.
Following the same principles, we can manually implement events that are triggered by clipboard actions, i.e. text is cut, copied, or pasted in the textbox. The .NET Framework does not come with these events, but they are not difficult to implement.
7/5/11 Update: Added support to suppress copy, cut, and paste events.
Custom Textbox
To implement custom events, we are going to have to create our own textbox user control. The user control will inherit the Textbox class since we want all the default behaviors of a .NET textbox.
Creating a custom user control will also let us override the WndProc function, which processes messages passed to the control. By overriding the function, we can detect messages such as when text is cut, copied, or pasted, before allowing the control to process them.
if you are using .asp webforms you need to change the text mode in your textbox
to SOMETHING LIKE THIS TextMode="MultiLine" Columns="50" Rows="5"
in Winforms
textBox1.Multiline = true;
Once I successfully validate user data in a TextBox (using TextChanged EventHandler), I'd like to programmatically tab to the next input control. I know I could hard code the name and do
Score2.Focus(Windows.UI.Xaml.FocusState.Keyboard);
but I've got 20 TextBox controls on the page page and I'd like to use the same EventHandler for all of them.
While it may be possible (iterate through the page's control inspecting their tab order and selecting the appopriate next control), I would recommend against it. It will irritate your user if they leave a text box to go back and correct a previous field but your app decides it knows better and gives focus to another field.
So im making a WPF project where one of my windows has to let the user see a text. Select parts of this text for being put into an array of strings and no more than that. So he/she musnt be able to edit anything in the text only highlight parts and then click on a button. What WPF control would be smart to use for this?
I'd probably just use TextBox with IsReadOnly set. The various selection properties are all you need after that.