.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

cascaded databinding

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :WPF
 

What do I do:

1. create a DependencyProperty P1 in class A (Window)
2. create a DependencyProperty P2 in class B (UserControl)
3. create the window A with a control B
4. bind P1 to P2, two-way
5. bind P2 to B's child control (say, Text)

What do I expect:
When I set P1, I want both P2 and Text to automatically update

What do I get:
After setting P1, P2 and Text are left unchanged (as if there was no binding between them)

I looked at it under the debugger and yes, P1 is set, P2 is null. I put a Trace.WriteLine in DependencyProperty's setter here and there and P2's setter is never called.
What am I doing wrong?




View Complete Post


More Related Resource Links

Need to remove databinding of DropdownList when another dropdown list changes

  

I have many controls on my form, but in particular, I have 2 dropdownlists.  1 dropdown list has 2 values, and each value controls what the second dropdownlist displays.  This is an edititemtemplate and both dropdowns have the selecteditem set via '<%# Bind("fieldname") #>' on page load.  

THe problem is, if I change the value of the first dropdown, it errors out because the second dropdwon has a bound value that is no longer acceptable. 

Can I cancel the bind of the second control, if the the first one is changed?  I would like to cancel the bind, and update the values by using a different datasource depending on the value of the first dropdown or hardcode the new values.

 

Currently.

If Dropdown1 has a value of "A" for example Dropdown 2 Shows Values "1", "2", "3"

If Dropdown 1 has a value of "B" , Dropdown2 Shows Values "4", "5", "6".

It binds fine initially, but if I change Dropdown1 from A to B, I want Dropdown2 to show the new values, maybe with a default of "Select an Item" and not error out b/c it's attempts to bind a value of 1, 2, or 3.

 

Hope this makes sence, b/c I'm

XNA and WPF, Databinding to a structs field such as Vector3 X Y Z

  
Hello people. Gonna go straight to the problem. I'm building a propertygrid with Datatemplates to define how each c# objects is gonna be shown on the UI. For example bools are drawn as checkboxes and strings are drawn as textboxes. A scenario where I'm having problems is with a class I've written called Transform. It contains the XNA struct Vector3 for position, scale etc. Xna Vector3 class members: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector3_members.aspx Quick example of the content in the Transform class: private Vector3 position; public Vector3 Position {     get { return position; }     set { position = value; } } I want the Vector3 struct to be drawn as 3 textboxes for each element X Y Z. But I can't databind directly to the X Y Z elements because the struct doesn't contain properties, the X Y Z elements are fields instead, and databinding can only occur through properties. A workaround I did was adding 3 new public properties for each element X Y Z in the Transform class. Example of X element only: public float WPFPositionX {     get { return position.X; }     set { position.X = value;} } This allows me to bind directly to the elements of the struct because it's a property and it works! But now there&nb

Accordian DataBinding problem

  
Hi Folks, I am having a strange problem with an Accordian control which is databound to a DataView. Each pane displays data about a person. The problem is that when a new person is added which sorts to one of the inner panes, it initially displays the content (but not the header) of the pane following. For example, if there are two panes, one for Andy and one for Mary, and I add a new person named Bill, then the headers will be Andy, Bill and Mary, as expected. But expanding Bill will show the info for Mary. Both Andy and Mary display the correct data.  If I leave the page and return, all displays correctly. I have stepped through the code, listed below,  and verified to my satisfaction that when I rebind the control, the data in the underlying datatable and dataview is correct. Any thoughts? Thanks. Dan   Here is the declaration of the Accordian control:  <cc1:Accordion ID="accPeople" runat="server"   Width="400px" Height="100" TransitionDuration="1" AutoSize="None"   RequireOpenedPane="false"  SelectedIndex="-1" ContentCssClass="AccCntnt" HeaderCssClass="AccHdr"   HeaderSelectedCssClass="AccHdrSlctd">  <HeaderTemplate>    <table >      <tr>  

Value changing to integer value when changing top drop down box from cascaded drop downs in Sharepoi

  
Hi, I have two drop down boxes named Categories and Sub Categories. When I select a category, the sub category populates fine and I can select the values where the category is equal to the category lookup field. But as soon as I then change the Category field again once I have selected both the category and sub category fields, the sub category field changes to an integer value? How can I change this so it just selects the blank value again?

WPF Databinding a combo box

  
I have looked at some of the other linked related articles but I still can't get it. Simply I have 2 related tables Orders and Customers when I am editing an order I want to display the Customer in a Combobox. Let's say I wish to change the customer using a cbo The Customer Combo box should be populated with all Customers from the customer table the currently selected customer should be the current customer in the Order Table  for the Order I am Viewing The display member should be the customers name the tables are related with a CustomerID field in each table The data is EDMX   I have done some work on databinding in WPF and I can get combo boxes populated with Data but it's just not quite there. I can't seem to get the selected cbo customer to update to the Orders  

XML databinding - accessing attributes of ParentNode from childNode in XAML

  
Hi All, I would like to get the ParentNode of a given childNode for the xml databinding in XAML. So what should I do ??? For instance: [XML] <Answer           Margin="40,1,1,1"           TabIndex="4"           Name="Answer"           DataType="bool"           Value="N">           <Option             Name="Y"             DisplayText="Yes"             MaxLength="1"             Width="20" />           <Option             Name="N"             DisplayText="No"             MaxLength="1"             Width="

databinding combobox which is inside a datagridtemplatecolumn

  
My datagrid is bound to a datacontext and I have a combobox inside a template column which has to be bound to a data source out of the existing datacontext.  I couldnt access that combobox from code behind. How can I achieve this. Also may i have a good learning resources for styling datagrid. Thanks :)   EDIT: I have two datatables in a dataset and my need is to intermix the data from both. Initially i set the data context to dataset.table1. Now I wanted to get values from other. So I tried the code-behind and found that I cant access elements in the datatemplate.   EDIT 2: I tried something like this: From code-behind: set Me.DataContext=mydataset And in XAML: when I wanted the values from 1st datatable: set the binding to table1/field. But I could see oly the first row of the datatable. 

Custom Control and DataBinding pb

  
Just Build a Simple Control with an embeded TextControl(RootTxt) and a Property Contents : Public Class Menu Inherits UserControl Public Sub New() InitializeComponent() VisualStateManager.GoToState(Me, "Normal", False) End Sub Public Shared ContentsProperty As DependencyProperty = DependencyProperty.Register("Contents", GetType(String), GetType(Menu),Nothing) Public Property Contents As String Get Return Me.RootTxt.Text End Get Set(ByVal StrContent As String) Me.RootTxt.Text = StrContent End Set End Property End Class When a Try to Bind Contents with a ressource Property it does not work : EX xmlns:local="clr-namespace:TMTemplate" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <UserControl.Resources> <local:ApplicationResources x:Key="LocStrings" /> </UserControl.Resources> ..... <local:Menu x:Name="menu1" Contents="{Binding Path=Strings.MainPage_SubTitle, Source={StaticResource LocStrings}}" FontFamily="Fonts/Fonts.zip#Genx Package" FontSize="17" Foreground="#FF0A0A0A" RenderTransformOrigin="0.5,0.5" Cursor="Hand">Any Idea bacause it's work q

How to set context key in Cascaded dropdown using javascript

  
I want to set the context key of a cascaded dropdown during pageload. means if tab index = 0 then contextkey = "1" otherwise 2;  function pageLoad(){ var index = $find("KMTabContainer").get_activeTabIndex(); alert (index); if (index ==0) { alert('Ravi'); var cntxtKey = $find("bScenario"); var ckey ="1" // alert(ckey); alert(cntxtKey.get_contextKey()); cntxtKey.set_contextKey(ckey); alert(cntxtKey.get_contextKey()); } else { var cntxtKey = $find('bScenarioAdd'); cntxtKey.set_contextKey("2"); } }  

Databinding to a property of a child entity.

  
<asp:Label ID="Label4" runat="server"                         Text='<%# Bind("EmployeeIdSource.EmployeeName") %>'></asp:Label>Is this kind of databinding permitted?

Nested Gridview and databinding

  
protected void grdClientPayments_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { GridView gv = (GridView)e.Row.FindControl("grdPayments"); SqlDataSource dbSrc = new SqlDataSource(); dbSrc.ConnectionString = NFMData.DB.GetDBConn(); dbSrc.SelectCommand = "SELECT APR.PaymentID, APR.AdID, PaymentAmount, PaymentDate, CheckNo, APR.Comments " + "FROM AdPaymentReceived APR " + "LEFT OUTER JOIN ISRPayment_Payments IPP ON IPP.PaymentID = APR.PaymentID " + "WHERE ISNULL(IPP.Amount,0) <= 0 AND APR.AdID = " + ((DataRowView)e.Row.DataItem)["AdID"].ToString(); gv.DataSource = dbSrc; gv.DataBind(); foreach (GridViewRow gvRow in gv.Rows) { if (gvRow.RowType == DataControlRowType.DataRow) { decimal PaymentAmount = (decimal)((DataRowView)gvRow.DataItem)["PaymentAmount"]; } } }   So basically what I'm trying to do is do some calculation on the rows in the sub-grid based on some values in the main grid.

Databinding to table that has a custom format

  
My problem is that I have a different format table for each section in my form. And I would like to bind data to these tables. A repeater I don't think is going to work. It would be great if I can do it like this:<table id="exampleOfWhatIWant" runat="server"> <tr> <td><%# Eval("data") %></td> <td><%# Eval("data") + 1 %></td> </tr> <tr> <td><%# Eval("data") + 2 %></td> </tr> <tr> <td><%# Eval("data") + 3 %></td> <td><%# Eval("data") + 4 %></td> <td><%# Eval("data") + 5 %></td> </tr> </table> Where the "+ 1" is the next record from that datasource --which is bound in code behind. Is there anyway, I can accomplish this without resorting to dynamically created tables (ugh).

Help with Databinding

  
Hello all,I have a table in my database called room. The columns in the table are roomid, roomtype and roomrate. On my asp form, I have a drop down control which I have databinded to the roomtype of the room table in the database. I currently want to display the corresponding roomrate in a textbox based on the selected roomtype from the drop down control. How do I go about it...... someone please help. Thanks in advance.

WPF Databinding a combo box

  
I have looked at some of the other linked related articles but I still can't get it. Simply I have 2 related tables Orders and Customers when I am editing an order I want to display the Customer in a Combobox. Let's say I wish to change the customer using a cbo The Customer Combo box should be populated with all Customers from the customer table the currently selected customer should be the current customer in the Order Table  for the Order I am Viewing The display member should be the customers name the tables are related with a CustomerID field in each table The data is EDMX   I have done some work on databinding in WPF and I can get combo boxes populated with Data but it's just not quite there. I can't seem to get the selected cbo customer to update to the Orders  

Race Condition with Databinding

  
Hi, I am facing a bit of a problem: My Model exposes a decimal Field I databind to. It's formattet through a StringFormat=\{0:c\} so I can't do a UpdateSourceTrigger="OnPropertyChanged" but rather have to rely on OnLostFocus to update my model. If the user fills out that field and then presses Save, it's not guaranteed that the new Data will be bound to the Model before the Save() is executed. Sometimes it will execute Databinding then Save, sometimes the other way around - resulting in my Save Command executing on old data. Is there some workaround or some fix to this? Btw: I use Caliburn with a MVVM approach so I can't interact with the View directly..  greetings Daniel 

WPF databinding problem with templates, kind of comlpex. Can someone help me?

  
Hey there, I have to following problem: In my MainWindow.xaml I declared a control like this: <Control Name="lvLeidingen" Template ={StaticResourceResourceKey =ListView}"></Control>   This creates a control which references to a resource ControlTemplate where a ListView is defined. which is done like this:   <ControlTemplate x:Key="ListView"> <ListView> <ListView.View> <GridView ColumnHeaderContainerStyle="{DynamicResource ResourceKey=ListViewColumn}"> <GridViewColumn CellTemplate="{DynamicResource ResourceKey=DiameterCell}"> </GridViewColumn> <GridViewColumn CellTemplate="{DynamicResource ResourceKey=WanddikteCell}"> </GridViewColumn> <GridViewColumn CellTemplate="{DynamicResource ResourceKey=BuisMateriaalCell}"> </GridViewColumn> </GridView> </ListView.View> <ListView.Items> <ListViewItem> </ListViewItem> </ListView.Items> </ListView> </ControlTemplate> And here are the DataTemplates for the celltemplates:   <DataTemplate x:Key="DiameterCell"> <ComboBox ItemsSource="{Binding Path=Diameters}"> </ComboBox> </DataTemplate>   The other templates for WanddikteCell and BuisMateriaalCell are done the same way..  

SSRS Databinding Programmatically

  
Hi people, Anyone got input as to how I can programmatically bind data to to SSRS reports with parameter? I need to make a data access layers class file and use it to bind to specific report. I am sure I'll need to do subreport eventually. I already did binding with the report wizard but I need to do it programmatically. I need to bind using stored procedures and eventually add other adaptor which is more of a propietary software. I need to grab field from a textbox and call/send it to a stored procedure. Once data return, I need to bind it to a report or generate a sub report. Is dataset my only option for data storage to bind? I am using VS 2010. So I believe that's SSRS 2008. BlueMarker
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend