Wpf - Bind To Custom Control Properties Defined In Code Behind

May 14, 2011

I have a custom control defined in code-behind:

Public Class MyControl
Inherits Button
Private _A As String

[Code]......

What code I have to write to bind to those properies?

View 1 Replies


ADVERTISEMENT

Referencing XAML Custom Control Names And Properties Within Code Behind?

May 13, 2009

I've created a Custom Control, and I will be placing a large number of instances of that Custom Control on my xaml page. In working with that Custom Control in the VB Code Behind, how do I do the following?

How do I reference the name of the Custom Control (in my VB code) which was clicked with the MouseLeftButtonDown event? For example, if I have 10 instances of my Custom Control in xaml, each with a different x:name (say 1-10), when a particular instance is clicked, how can I see which one was clicked? I've tried a number of things including e.OriginalSource.Name (which returns the component within the control which was clicked and not the name of the instance of the control). My Custom Control consists of numerous parts and pieces (Rectangles, Lines, Text, etc). Each of these items is a part of my layer. In VB code, once I can reference a particular Control, how can I hide or change certain parts of that control (such as hiding a Line, and changing the text). Also, I need to modify more than just the control which was clicked, so I need to be able to access properties of all of the controls, not just what was clicked. For example, if I click Control instance Test1, I also need to modify Test2, Test3, and Test5 in some way.

Here is some test code I through together as part of a Silverlight project using MS Blend 2. My control is much larger, and I need 200 - 250 instances/copies of that custom control, so I really need to know which control instance/copy was clicked.

My UserControl:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

[Code].....

View 1 Replies

Get Custom Properties For A Custom Control Into The Visual Studio Properties List?

Nov 25, 2009

What I've done is create a User Control Library (Project) and I've added a single User Control to that project. The control contains a single FlowLayoutPanel, and I created a Property on the control itself to pass the FlowDirection from the Control to its FlowLayoutPanel child.

Build, reference, component appears in the Toolbox and everything works fine, but the property on the control does not appear in the Properties window when I go to edit it at design time.

View 6 Replies

How To Bind Custom Class With No Strongly Typed Properties

Mar 10, 2009

I need a simple class with only one Public property and no Public methods (the final Class will be more complex, but for testing this is all I need). The Property is "Item" and takes a "String" as a parameter. It returns a "String" based on the parameter. I then want be able to add instances of this object to a List or Array, and then Bind it to a Repeater or a ListView......most importantly, I want to be able to then refer to values in my simple Class via the Eval function:
<%# Eval("SomeIDString**") %>**.

I can't Bind at all unless I declare the Item property as the Default property...why?
When I use "Eval", I get an error in the lines of "[some property] does not exists". indeed it doesn't, because everything is accessed via the Item property. it then does works if I replace "Eval" with "Container.DataItem". Is there a way to use Eval instead of Container.DataItem? I would rather not have my class inherit any other classes because I want to keep it clean from supurfulous properties and/or methods.

Are there interfaces I need to implement? Also, the reason I want to use Eval, is that as much as possible, I want to make the use of this Class simple, so the coder doesn't need to worry about special cases. I just want it to work, much like the DataTable Class, but with a much simpler, lighter-weight implementation.

View 3 Replies

Bind A WinForms TreeView Control To Some User-defined Objects?

Oct 16, 2011

I'm trying to bind a WinForms TreeView control to some user-defined objects. In particular, I'd like to bind aTreeNode.Text property to myObject.Name. My strategy is to create xTreeNode, a subclass of TreeNode, add a DataBindings collection, and expose its Text property. This would allow me to write some code like this:

Dim oBinding as Binding
Dim bs as New BindingSource
bs.DataSource = myObj

[code]....

View 1 Replies

Make Custom Properties In Properties Window To Refresh Upon Change Via Code?

Apr 26, 2012

[code]I want to make the Properties Window to update the properties for X and Y at each MouseMove, so they become immediately visible for the user.

View 2 Replies

.net - Bind Multiple Properties On The Same WPF Control?

Jan 12, 2012

I am able to bind my datasource to the textblock for the display text. However I would like to set the Fontweight to bold if the value of the checkbox foo is checked. I'm trying to use IMultiValueConverter to accomplish this, but have had no luck so far.

<CheckBox Name="foo"/>
<TextBlock Name="bar" Text="{Binding Path=Name}">
<TextBlock.FontWeight>

[Code]....

View 2 Replies

Bind The Properties Of A Control To A DataTable Object?

Feb 8, 2011

What I want to achieve is to Bind just some of the properties of a Control to a DataTable object.Let's say I have a Label on the Form : "MyLabel1".MyLabel is a Class that inherits from Label and adds a property "ID", an Integer, to the base class.

I want to Bind .Left and .Top properties of MyLabel1 to a DataRow in my DataTable, and I want to see them updating, everytime I change MyLabel1 location on Form. I put description and full code, so everyone can test it in minutes :

I have :

--> A Form, with a DataGridView "DGV" : The DGV is for showing at real time the desired properties of the controls I want to bind ( in this case, just one control : MyLabel1 ).

--> MyLabel Class :
Public Class MyLabel
Inherits Label
Private m_id As Integer

[code]....

View 1 Replies

Integrate / Bind Date Custom Control

Feb 23, 2009

I'm trying to integrate a custom control that I built into my vb.net project. My control contains 4 text boxes Month, Day, Year, and Time. My database field is a datetime field in SQL Server 2005.I am able to bind the data, but my control doesn't work when a date isn't entered. I'm pretty sure that this is a DBNull issue. I need to be able to insert NULL into the database when a date isn't entered. When a date is entered, I want to insert that date into the database. With the below code, I can't tab out of my control when a date isn't entered.

[Code]...

View 1 Replies

Bind A List Of Custom Objects To A Listbox Control?

Jun 25, 2010

vs2010 vb.net WPF project

This is an experiment to learn something.

I have a class called logitem

it has a datetime property, and a message as string property

I have declared myLogEntries as List(of logItem)

I have a ListBox.

Ok now what?

I have searched but i am getting lost in all the examples.

I have set the ItemsSource=myLogEntries

I think i need a datatemplate or maybe to specify binding source.

I am doing all this in the wpf form loaded event.

I guess i need a sample code for binding a list of collection to a listbox.

View 5 Replies

.net - Group Properties In A Custom Control?

Apr 16, 2009

In our IDE, for example, Visual Studio, if we display the properties of a System.Windows.Forms.Button control, we see some properties that expose anoter set of properties. For example: FlatAppearance, Font, Location, Margin, etcetera.I would like to do something similar in a custom control.I know the code behind is wrong, but here is an example of what I´m trying to do:

Public Class StateOfMyCustomControl
Public Enum EnumVisibility
Visible

[code]....

In my IDE, in the properties window of my custom control, I would like to see my property State, with the possibility of display it to set the properties Visibility and EventManagement.

View 1 Replies

Group Properties In Custom Control?

Apr 10, 2012

I want to do a class that have properties like font, which will have other properties, such as name, size, unit,bold.

<TypeConverter(GetType(ExpandableObjectConverter))> _
Class TestingClass
'Some property here
End Class

View 1 Replies

Reusable Custom Control With Properties?

Nov 13, 2009

I have built a Custom Control Class that makes it much easier to build a side bar element in my html.

The problem I am running into is that when I set the "Text" property, the last time I set it gets used for every instance of the control on my page. This is my first time doing this, so I'm assuming I'm missing something basic.

[Code]...

View 1 Replies

Set The Properties On A Custom Control In The Designer?

Mar 21, 2010

Is it possible to make a form that can set the properties on a custom control in the designer? What I mean is I want to know if it is possible to show a dialog that allows you to set the settings for a certain property like if you were adding items to a listbox.

View 3 Replies

Create Custom Control With Reusable Properties?

Nov 14, 2009

This is similar to my last post but with a different purpose.I have built a custom control, but when I set the properties for it... ALL instances of that control on my page grab the exact same property. I need to be able to set the property to "abc" for one instance of the control on my page, and then set the exact same proprty to "xyz" for a different instance of the control on the same page.

[Code]...

View 1 Replies

Custom Control - Make Properties For Strings Etc?

Mar 16, 2010

I have a custom list control, using labels to display content.How can I add a list property to the control so I can inject items into the custom listbox?I know how to make properties for strings etc. but I can't get it to work to make a list property...

View 1 Replies

Usercontrols - Properties Not Passing To From In .NET Custom Control?

Mar 6, 2012

I have a custom VB.NET control that I created that is working correctly in one program but not in another.The control has one button and one form. The form displays some data based on the settings in the control.

[Code]...

In TestProject1 - the control is working as expected In TestProject2 - the control is not sending any of the settings I set to the form My control works fine when I debug with the UserControl TestContainer.

I am using VB.NET on VS2005. This is all done on the same machine. Why would this work in one project and not another?

View 1 Replies

VS 2008 PropertyGrid And Custom Control Properties?

Aug 12, 2010

I have a custom control and have created some properties for it.When I click on that control, its properties are then shown in the PropertyGrid.The problem, is that I only want to show some of the predefined properties as well as my custom properties.Does anyone know how I can filter out the properties I want shown?

View 9 Replies

Custom Control - Combined Properties Partially Working

Aug 15, 2011

Asking for little guidance again... For my custom control, I grouped some properties in some class. Then in the main control code, I use:

[Code]...

View 7 Replies

User Control With Simple Textbox - Custom Properties

Oct 15, 2011

I've created a user control with a simple text box and a corresponding label and added a few custom control properties. When added to a form, I'm trying to loop through all control of this type and evaluate the custom property. In the below, the cntl.MyCustomProperty is not recognized. I can evaluate the property when I check each user control on the form by name, but not by using the loop below. I would much rather use the loop as it is much cleaner.

For Each cntl As Control In Me.Controls
If (TypeOf cntl Is MyUserControl) And cntl.MyCustomProperty = "ABC" Then
''Do some stuff
End If
Next

View 2 Replies

Load A User Control In An Ajax WCF Service And Access Custom Properties?

Apr 4, 2011

I can load a generic user control just fine in my WCF service doing the following:

UserControl userControl= (UserControl) new Page().LoadControl("~/UserControls/MyControl.ascx");
However i can't seem to find any way to do this

[code].....

View 2 Replies

PropertyGrid Custom Properties - Custom Sub Properties

Oct 21, 2009

I've populated a PropertyGrid with a custom class. How do you create and display a sub property similar to Size (Height, Width) which has two values or Point(X,Y)? For example, the class is Test and the property is Item as string. I want to expand Item to have two sub properties, A and B.

View 1 Replies

C# - Use ResolveUrl() To Set Some Paths In The Code Behind Of A Custom ASP.NET User Control?

Mar 31, 2010

I'm trying to use ResolveUrl() to set some paths in the code behind of a custom ASP.NET user control. The user control contains a navigation menu. I'm loading it on a page that's loading a master page.When I call ResolveUrl("~") in my user control it returns "~" instead of the root of the site. When I call it in a page I get the root path as expected. I've stepped through with the debugger and confirmed, ResolveUrl("~") returns "~" in my user control code behind.Is there some other way I should be calling the function in my user control code behind to get the root path of the site?

View 4 Replies

Globalization - Globalize Custom Control Text In Code Behind

Jun 12, 2012

I have a web application which uses the globalization values being passed from sql server 2005 using a ResourceProviderFactory. I can globalize the labels in UI using <%$ Resources: "Resourcekey" %> however, i wish to know how i can globalize the dynamic/custom controls available in the code behind of my vb.aspx page?

View 1 Replies

Markup Code Inside Custom Server Control?

Dec 29, 2010

I'm new to custom server controls and I'm hoping to use them to build various 'modules' for different sites I build to cut down on duplicate code.

I'm familiar with custom user controls in which I can create an .ascx & .ascx.vb file which can then be imported into an .aspx page and used freely.

However, with custom server controls I cannot find a way of using markup/html code. Is this possible at all or must all code be created programmatically?

View 1 Replies

Dynamically-defined Properties In .NET?

Oct 8, 2009

I've created a couple of Comparer classes for FileInfo objects to allow sorting by Name and LastWriteTime properties, but ideally I'd like to combine them into once class, so that I can compare/sort by any property simply by passing through the chosen property name.However, I don't know how to go about this. My comparer class current includes:

Dim oX As FileInfo = CType(x, FileInfo)
Dim oY As FileInfo = CType(y, FileInfo)
Dim Result As Int16 = oX.Name.CompareTo(oY.Name)

I want to be able to substitute the Name property with the property name stored in the _sortColumn variable.I'm expecting the solution to be rather simple, but as yet, I haven't been able to figure it out!

Solution:I'd already got as far as researching Reflection, and had stumbled across PropertyInfo. But Fredriks solution cut down my search and provided a bit of structure, and I've come up with this (VB.Net) solution which seems to work nicely:

[Code]...

View 2 Replies

C# - Bind To The Difference Of Two Properties From Different ViewModels

Jan 12, 2011

I have two viewmodels (each with their own models):
AmendmentViewModel
YearViewModel

each have a property:
AmendmentViewModel.TotalAmended
YearViewModel.TotalCommitted

On the view there is a TabControl and each of the viewmodels is the datacontext for a tabcontrol page. Yes i know I could technically use one view model but its a LOT of code and a large view that Has to be in a tabcontrol. How do i set the binding of a TextBox to the sum of AmendmentViewModel.TotalAmended & YearViewModel.TotalCommitted ?

View 1 Replies

Asp.net - Programmatically Change Custom Attributes Of User Control In Code Behind?

Jan 21, 2012

I have a User Control which is a customer input form.I'm working on a sales system, when generating a sale, the customer data is populated by a Javascript Auto Complete, but when loading a saved sale, I need to paste a User ID into the control programatically.

<controls:customerDataForm ID='customerForm1' partExchangeMenu="true" showBankDetails="false" customerID="****" runat='server' />

Renders my control on the page within the markup of the parent document (in this case it's called newSale.aspx)In the code behind in newSale.aspx.vb I need to be able to programmtically change the value of the Controls customerID attribute. I can't seem to do it.This is what I have done, following various Googling attempts, but it is always leaving the customerID as zero

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
customerForm1.customerID = "0" '// default Customer ID if no invoice number
If Request.QueryString("invno") <> "" Then

[code]....

View 1 Replies

Creating Custom Control By Inherits BindingNavigator - How To Add ToolStripItem By Code

Sep 28, 2010

I'm creating a custom control which inherets the BindingNavigator.I need do add one ToolStripButton at specific posistion (9 element) on the ToolStrip of the BindingNavigator.So, I wrote the following code:

[code]...

View 7 Replies

C# - Cecil - Getting The Defined Attributes Properties?

Aug 7, 2009

I am using Cecil to try to read my attributes properties:

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class TraceMethodAttribute : Attribute {
public TraceMethodAttribute() {
MethodStart = true;

[code]....

This is, I'd like this last block of code to check whenever the attribute applied to Main, for example, has MethodMessages set to true or false. From what I've seen, it seems like both attributes.Fields.Count and attributes.Properties.Count is set to 0. Why is it?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved