w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Binding in User Controls
SomeClass must impelement INotifyPropertyChanged or have event named NameChanged if you want bidirectional data binding. You can implement it yourself, but I highly recommend Fody.PropertyChanged project. PS: I wrote some extension method to create binding more easier and refactoring friendly way. In your case it would look like this: this.BindTo(inClass, c => c.MyName , m => m.Name); The method itself: public static class BindingExtensions { public static Binding BindTo<TControl, TControlProperty, TModel, TModelProperty>(this TControl control, TModel model, Expression<Func<TControl, TControlProperty>> controlProperty, Expression<Func<TModel, TModelProperty>> modelProperty, string format = null) where TControl : Control { var

Categories : C#

which one is better in terms of performance, the early binding or late binding in Delphi COM objects
Which one is better in terms of performance? Early bound is quicker than late bound. Late bound method dispatch involves the following: Looking up the entry point from the name. Assembling the parameters to be passed to the method, and performing any necessary type conversions. Calling the function. Unmarshalling any out parameters and the return value. Many of these steps are not present at all for early bound dispatch. Of course, if the function does anything significant at all, the performance different during method dispatch may well not be detectable.

Categories : Delphi

How to make binding from user control to property of parent control?
ElementName binding works within in same XAML scope. This will work - <Grid> <CheckBox Name="checkBox1"/> <Label Content="{Binding ElementName=checkBox1, Path=Name}"/> </Grid> But if you want to do it in different UserControl, you have to tweak a bit your code and use Tag to hold name - <Grid> <CheckBox Name="checkBox1"> <local:UserControl1 Tag="{Binding ElementName=checkBox1, Path=Name}"/> </CheckBox> </Grid> UserControl.xaml <Canvas> <Label Content="{Binding Path=Tag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"/> </Canvas> On a sidenote, in your UserControl, you know you need to bind with ElementName = checkBox1 and that's

Categories : Wpf

FlowLayout Control With User Control Item Template Not Binding
Try: public UserControl2() { InitializeComponent(); Loaded += (sender, args) => { var obj = (ViewMod)this.DataContext; if (obj == null || obj.Prop == null) return; var d = obj.Prop; if (d == null) return; grd2.Children.Add(new TextBlock { Text = d.Name }); }; } DataContext is not set instantly. Hence we use the Loaded event and add a lambda to it to do your corresponding steps. side-note: even-though this works, please do search and look at some MVVM examples. While having no code-behind is not really an MVVM requirement, I think your taking it a bit too far adding Grid children and stuff from code-behind when you can do it perfectly fine from xaml.

Categories : C#

How to binding data to and register property in user controls WP8
Sounds like you're basically asking "How do I do binding". A good read is: http://msdn.microsoft.com/en-us/magazine/hh852595.aspx and nearly any other Binding resource you find out there. In your case you will need an object that has a Title and a ImageSource property that is set as the DataContext of the control (or one of its parents like the PhoneApplicationPage). You can set the DataContext from your code behind (or in XAML) (if you're on the Page then you can simple set DataContext = ....

Categories : C#

Placing controls under User Control
I'm pretty sure that that won't work. When you set the content of MyControl to the button you're saying that the whole content of the user control should be the Button. I think you need to have a property on your user control then bind the contentpresenter to that. So Something like MyUserControl.SubContent {get; set;} then you can bind the ContentPresenter to that.

Categories : C#

Initialize String List property on User Control
You can do it by other way. Add other property of type string, you can name it is as ListData. This will be in usercontrol public string ListData { get; set; } Assign string with comma separator to this property <uc1:MyListControl ID="MyListControl1" runat="server" ListData="ABC,XYZ" /> You can parse this string to List in page_load of usercontrol. protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ListData)) { MyList = ListData.Split(new char[] { ',' }).ToList(); } } Now you can use this MyList as list populated with data

Categories : Asp Net

Accessing MainWindow's controls from a user control page. WPF C#
You could find the WpfPageTransitions.PageTransition control like this from the UserControls code behind: public static WpfPageTransitions.PageTransition FindPageControl(DependencyObject child) { DependencyObject parent= VisualTreeHelper.GetParent(child); if (parent == null) return null; WpfPageTransitions.PageTransition page = parent as WpfPageTransitions.PageTransition; if (page != null) { return page; } else { return FindPageControl(parent); } } Then you can use it like this: this.FindPageControl(this).ShowPage(...);

Categories : C#

User Control embedded on a page changes ClientID of controls
This happens because your control is a subclass of UserControl class, which implements INamingContainer interface. By default all controls that implement this interface prepend children's IDs with their own IDs, thus insuring that every ID on the page is unique. To aviod this behavior you have two options: Create server control, inheriting not from UserControl but from Control class directly. This one does not implement INamingContainer. However you won't have markup file, and have to generate all controls programmatically. [Edit: ASP.NET 4 only] Use ClientIDMode="Static" for child controls. This mode insures that server and client IDs of the control are exactly the same. In this case this is a job of a developer to make sure that this control is used only once on the page to avoid ID d

Categories : C#

Access controls not properties in XAML User Control
Check out these links C# usercontrol how to access all child controls how to get child user control by id from a parent panel user control? http://www.daniweb.com/software-development/csharp/threads/141469/how-to-access-child-control-of-a-user-control

Categories : C#

Accessing controls located in a dynamically created user control vb.net
As @HansPassant said you just need to add properties to your user control to get access to your controls in it. I'm not a vb.net guy, but I think this is going to help you: Public Function MyTextbox() As System.Windows.Forms.TextBox Return Textbox1 End Function You can write this in your user control code.

Categories : Vb.Net

Dynamically load User Controls into a Web Control without Register Tags
Well you can load them dynamic on page load like this: private const string UCFolderName = "~/Controls/"; ... var usercontrolA= Page.LoadControl(UCFolderName + "UsercontrolA.ascx"); ServercontrolContainer.Controls.Add(UsercontrolA); where ServercontrolContainer is a element in your .ascx file

Categories : C#

Load a user control in Wpf via binding
You can use a ContentPresenter instead of the StackPanel, since there is only a single element: <ContentPresenter Height="500" HorizontalAlignment="Left" Margin="0,46,0,0" VerticalAlignment="Top" Width="500" Content="{Binding SomeUserControl}" />

Categories : C#

Is there a concept like late binding in in jsf
I resolved the issue by adding a condition to the ui:include tag ie <ui:include src="#{bean.state=='somevalue'?'a.xhtml':'b.xhtl'/> so my page that has the binding attribute will be set only when the particular condition is satisfied other wise a dummy page is shown. This resolved my issue

Categories : JSF

How to set binding for Width for any user control in Silverlight?
I have not experience in WPF, but in silverlight Width and Height values are of type Double. You should not have problems binding it to an integer, however, as silverlight can take care of such things easily. Maybe a description of what you intend to do and what really happen, and a more detailed code sample could help. EDIT: That explain all. Width property of a FrameworkElement is a Double type property, but width property of a grid column is a diferent story. Columns of a grid are defined by a collection of ColumnDefinition objects, and their width property is a GridLength type, not a double, since grid column width may take literal numeric values, auto value, and star values (*). However, this is a mere curiosity, since columndefinition class is not derived from framework element,

Categories : Wpf

How to declare a method when using late binding
CentimetersToPoints is a method of the application object. Qualify the method name using the name of the application object variable. With objWordApp.ActiveDocument.PageSetup .TopMargin = objWordApp.CentimetersToPoints(0.5)

Categories : Ms Access

Knockout late binding with MappingOptions
Check out the documentation observing_only_certain_properties_using_observe. Following the provided example you can use observe on direct object not on an array. So you need to apply your mapping on the object level not the array level. I have made simple code of you: function ViewModel() { var self = this; self.mapping = { //observe: ["Number"] create: function (options) { //customize at the root level. var innerModel = ko.mapping.fromJS(options.data, { observe: ["Number"] }); return innerModel; } }; self.infos = ko.mapping.fromJS([]); //self.infos = ko.observableArray(); self.load = function () { // Ajax-Call var data = [{ "Name": "MyName", "Number": "12345" }, { "Name": "MyName

Categories : Javascript

JavaScript Equivalent of Late Static Binding
In your JavaScript code, there's nothing static (or even "static-like"). To simulate static variables, you can attach properties directly to constructors: function my_pet(){} my_pet.name = "paulie"; function my_dog(){} my_dog.name = "stacey"; However, to achieve what you're looking for, you may want to use the prototype chain instead: function my_pet(){} my_pet.prototype.name = "paulie"; function my_dog(){ this.name = "stacey"; } my_dog.prototype = Object.create(my_pet.prototype); var stacey = new my_dog(); console.log(stacey.name); //stacey console.log(my_dog.prototype.name); //paulie delete stacey.name; // no more shadowing console.log(stacey.name); // paulie

Categories : Javascript

What is early (static) and late (dynamic) binding in C++?
You read right. The basic example can be given with: using FuncType = int(*)(int,int); // pointer to a function // taking 2 ints and returning one. int add(int a, int b) { return a + b; } int substract(int a, int b) { return a - b; } Static binding is when binding is known at compile time: int main() { std::cout << add(4, 5) << " "; } leaves no room for a dynamic change of the operation, and thus is statically bound. int main() { char op = 0; std::cin >> op; FuncType const function = op == '+' ? &add : &substract; std::cout << function(4, 5) << " "; } whereas here, depending on the input, one gets either 9 or -1. This is dynamically bound. Furthermore, in object oriented languages, virt

Categories : C++

PHP __DIR__ evaluated runtime (late binding)?
You can add the following code in getDir method of Parent class $reflector = new ReflectionClass(get_class($this)); $filename = $reflector->getFileName(); return dirname($filename); Your parent class will look like this abstract class Parent { protected function getDir() { $reflector = new ReflectionClass(get_class($this)); $filename = $reflector->getFileName(); return dirname($filename); } } Hoping it will help.

Categories : PHP

AutoCad: Getting 'Invalid object array exception' in Late Binding while copying Objects
You can late-bind cast to an object. http://www.dicks-clicks.com/excel/olBinding.htm You can use entities: http://msdn.microsoft.com/en-us/library/gg309272.aspx or the Dynamic and cast to a similar object definition or property bag, if you will. In Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online, you can use the Entity class when you work with entities. In Microsoft Dynamics CRM 4.0, you used the DynamicEntity class. When initialized, the Entity class contains the logical name of an entity and a property-bag array of the entity’s attributes. This lets you use late binding so that you can work with types such as custom entities and custom attributes that were not available when your application was compiled. Because the entity base class always contains the property bag

Categories : Visual Studio 2010

RaiseEvent between User Controls where there are multiple instances of the same controls on one page ASP.net
The solution I found to this problem is from an old article from 2002 on Code Project. Here's the link to that article ASP.NET User Controls - Notify One Control Of Changes In Other Control. After reading that article and looking through sample code, here are the following changes I made to the code above. There are no changes to the ASPX files except the following line in the Output ASPX file should be removed. <%@ Reference Control="~/Input.ascx" %> First you add a new class called LabelChangeEventArgs. Public Class LabelChangeEventArgs Inherits EventArgs Private _LabelStr As String Public Property LabelText() As String Get Return _LabelStr End Get Set(value As String) _LabelStr = value End Set End Pro

Categories : Asp Net

DNN: Using multiple web user controls in one module and showing different controls in different pages
Astro, Option 1: You need to go to Host > Extensions > Edit your extesion > Expand Module definition and click on add control. Here you have to select your ascx control and provide key as any string. Let's say you provided key test, you selected user control and selected control type as view and saved it. Now from view you can use following code to navigate to the newly added control: DotNetNuke.Common.Globals.NavigateUrl(TabId,"test","mid="+ModuleID); This will redirect the page and load your page with test.ascx. You can use this kind of option when you want to show view.ascx by default and want to switch view when on some action and show test.ascx. Disadvantage here is, when you switch to test.ascx, all other modules added to page will not be visible. Option 2: You have to creat

Categories : C#

using custom controls instead of user controls to create complex views
Unless you need the functionality provided by custom controls, I would suggest using UserControls or DataTemplates. They are simpler. Here's a related questionanswer. WPF User Controls vs Custom Controls

Categories : Wpf

Initialize multiple js controls by searching DOM only once
I can imagine using a common name and function names in your class names. E.g. something initFunc1, something initFunc2. Then, find all nodes with something, extract the second classname and call the corresponding function. <a class="something initFunc1">x</a> <a class="something initFunc2">x</a> <a class="something initFunc3">x</a> Example: <script> var A = $('.something'); for(var i in A) { var fn = A[i][0].className.split(' ')[1]; window[fn]( A[i][0] ); } </script> There are many ways this can be done. The above solution requires the init functions to be declared on the window object, and they receive the node as parameter.

Categories : Javascript

DotNetNuke User control not working .it shows data from .resource file in Portal>0>cache>pages.Not able to debug User control
I have a series of DNN tutorials that I started on recently (I wrote a majority of the old ones on dotnetnuke.com) that talk through the process of setting up your development environment, and then using the Visual Studio Templates that I have created/released (open source). I would encourage anyone trying to really do any development with DotNetNuke to check those out. http://www.christoc.com/tutorials

Categories : C#

Late-Binding Exception Calling Generic Method of Generic Type in C#
Your GetFirstGenericArgument() is wrong. Calling GetGenericTypeDefinition() returns the underlying open generic type. Its type argument is T. Instead, you should write t.GetGenericArguments()[0], which will get the value of the generic type parameter for the closed type. No; your code doesn't make any sense. What on earth are you trying to do? I suspect that you actually want to write public class CollectionHandler<T> { public void Handle(IEnumerable<T> collection) { // Look ma, no reflection! } }

Categories : C#

Open User Control from user control in main window grid WPF
This is just a guess as you've not provided much information, but I noticed the following issue which may be the culprit. In your first code snippet, you seem to be creating the employee from the MainForm: Dim Empl As New Employee MainGrid.Children.Add(Empl) Grid.SetRow(Empl, 1) Your following comment would seem to confirm that assumption: This is from Window_Loaded event. Menu is User Control, and there I have few buttons to open and operate another user controls. When I press for example button "Question" And yet, in your Employee class, you are creating a brand new instance of MainWindow and then adding data to it: Public Class Employee Dim mw As New MainWindow Private Sub btnQuestionAdd_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnQu

Categories : Wpf

I can not display binding value of a custom control's property when control loads
Try binding SelectedItem property to ControlTemplate <ScrollViewer x:Name="PART_ContentHost" Content={TemplateBinding SelectedItem} SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Stretch"/>

Categories : Dotnet

Losing styles when adding a User Control to a User Control
In general it is good practice to keep your styles separate from the markup. This makes maintenance easier and it also saves yourself from searching for the reason one of your elements appears a pixel away from where you are expecting (for example... Similar issues can be exasperating). Do you have the same issue if you set the CssClass attribute for your button(s) and set the styles in a css file for the class?

Categories : C#

WPF user control bind data to user control property
You can try Element binding inside the user control. Just give a name to UserControl and bind property: <UserControl x:Class="controlmaker.checkButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="114" d:DesignWidth="221" x:Name="MyUserControl"> <Grid Background="Aqua" > <CheckBox Content="CheckBox" Height="16" HorizontalAlignment="Left" Margin="58,24,0,0" Name="checkBox1" VerticalAlignment="Top" /> <Button Content="{Binding Path=buttText, ElementName=MyUserC

Categories : Wpf

Data Binding for nested controls
The UI has currently no way of knowing when the source changes. You need to either use an ObservableCollection or implement the INotifyPropertyChanged interface to properly notify the UI when the source changes.

Categories : C#

Binding controls dynamically to PlaceHolder in asp:DataList
You are not adding the control to the page. You need to add it: Control ctrl = (Control)Page.LoadControl("MyControl.ascx"); // MyControl ctrl = new MyControl(); ctrl.SomeProp = "xyz"; ph.Controls.Add(ctrl);

Categories : C#

Umbraco - Using .net macro in editor with binding controls
I've encountered this same issue. This happens because of the way the controls are nested in a different container in the editor and thus a standard FindControl() won't find it. I've implemented Rick Strahl's recursive FindControl() helper method in all of my projects and that usually solves the problem: http://www.west-wind.com/weblog/posts/2006/Apr/09/ASPNET-20-MasterPages-and-FindControl Usually I put it in a static ControlHelper class and call it like so: ((TextBox)ControlHelper.FindControlRecursive(this, "txt_name")).Text = "name"; Optionally you can turn off the "Render Control in Editor" option in the Macro settings. 99% of the time I turn this off anyway since most of my macros don't require the presentation to display in the editor.

Categories : Asp Net

binding to large datasets to JQuery controls
Passing a million coordinates to JavaScript will only lead to a lot of pain. Your best option for viewing large datasets on a JavaScript map is to turn it into an image on the server side and overlay it on the map. Take a look at this code project: http://ajaxmapdataconnector.codeplex.com/

Categories : Javascript

Is there a well-defined pattern for binding controls to asynchronous data?
As others have noted, the "asynchronous" members in WPF types have nothing to do with async and await. You do have a problem in your binding; your path is using Task.Result, which will block the UI thread until the query is complete. Also, using Result brings up the possibility of a deadlock that I describe on my blog. I have another blog entry that deals with async properties, in particular how to data-bind to properties that are (logically) asynchronous. My AsyncEx library has a type called NotifyTaskCompletion that allows you to data-bind more naturally to an asynchronous Task. So, e.g., you could do something like this: public class HottestPageProxy { public HottestPageProxy() { Artists = NotifyTaskCompletion.Create(GetArtists()); } public INotifyTaskCompletion<Arti

Categories : C#

How can I get my web controls to display over an activex control?
Short Answer, and the solution i used, was to stop using activex, or just use a plain select box, which will render over the control. Any of the nice CSS/Jquery select boxes (select2, chosen) will not display over activex...

Categories : HTML

one COMBOCHART that control by Controls and dashboards
This appears to be a duplicate of the issue posted in the Google Visualization API forums (here), but for the StackOverflow crowd, here is my response: I see a few potential issues here: you are populating a <select> element with options and then immediately firing the "change" event handler, which expects there to be a selected <option>, but you don't set a default selected option, so this will return null (or undefined, or error out, depending on how picky the browser is). you are creating a new div with the id "ComboChart" and appending it to a div with the id "ComboChart". If "ComboChart" already exists, you are breaking the HTML rules that require elements to have unique IDs (which could cause this problem); if "ComboChart" doesn't already exist, then you are failing t

Categories : Javascript

foreach control c# skipping controls
Surprised that's not erroring on you, since you're modifying the collection as you're iterating over it. Use a for loop and start at the end: for (int ii = Controls.Count - 1; ii >= 0; ii--) { Control cntrl = Controls[ii]; Controls.remove(cntrl); cntrl.Dispose(); } (Starting at the end because otherwise you'd be changing the indexes of each control as you iterated.)

Categories : C#

How to hide control when other two controls are already hidden?
you can use Multibinding and a MultiConverter on Label1.Visibility to do this job or you use Style Trigger for your Label1 and set the initial visibility to hidden and use 2 triggers to set the visibility to visible if one of the controls are visible EDIT <Label x:Name=Label1> <Label.Style> <Style TargetType="Label"> <Setter Property="Visibility" Value="Hidden"/> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=ctl1, Path=Visibility}" Value="Visible"> <Setter Property="Visibility" Value="Visible"/> </DataTrigger> <DataTrigger Binding="{Binding ElementName=ctl2, Path=Visibility}" Value="Vi

Categories : Wpf



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.