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


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

ContextMenu databinding?

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :WPF
 

     <TreeView>
                <TreeView.Resources>
                    <ContextMenu x:Key="TestContextMenu">
                        <MenuItem Header="Item One" Click="ItemOne_Click" />
                        <MenuItem Header="Item Two" Click="ItemTwo_Click" />
                    </ContextMenu>
                </TreeView.Resources>
               <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
          &


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

Adding ContextMenu to WorkflowDesigner View

  
Hello Everyone,      I am trying to add the ability to have a user highlight an activity subtree, then right click the mouse, then select "Extract activity".  Which will then take out the xaml (ModelItem) selected, create a new activity out of it, then insert this newly created activity in its place.  Right now I'm stuck on getting a ContextMenu to appear when I right click in the designer area.  I can get my custom context menu to work in other places on the same window however.  Does anyone know the solution to this problem?  Also, does anyone have any better suggestions as to how I might achieve the same end result in a more efficient manner? Thanks everyone, Bob

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>  

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  

how to control multiple and different ContextMenu?

  
I have a DataGrid (.Net 4), it got its own ContextMenu. at runtime, this DataGrid will have an Adorner dynamically created over it for custom drag-N-drop feature, and this Adorner/base also has its own ContextMenu. my problem is i wanna see the DataGrid's ContextMenu, but instead the Adorner/base ContextMenu shown. If i fool around with the mouse right-click over the DataGrid randomly/fast-clicking, sometime I can get 2 of their ContextMenu pops. how can i control, to only show DataGrid contextMenu pop, and stop the other shown?

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="

get parent of contextmenu

  
i have menuitem in a contextmenu assigned to image control how can i get the image handler in the click funtion of the menuitem? thanks in advance

Dynamically remove WPF contextmenu subitems?

  
Hi, How can I remove an item that is a subitem of a menu item? Snippet Snippet< UserControl.ContextMenu >          < ContextMenu  Name = "ContextMenu"  >              < MenuItem  Name = "Copy"  Header = "Copy"  Click = "Copy_Click"  InputGestureText = "Ctrl+C" />              < MenuItem  Header = "Cut"  Click = "Cut_Click"  InputGestureText = "Ctrl+X" />              < MenuItem  Header = "Paste"  Click = "Paste_Click"  InputGestureText = "Ctrl+V" />              < MenuItem  Name = "SendToItem"  Header = "Send To" >                  < MenuItem   Name = "RemoveItem"  Header = "REMOVE"  Click = "CopyToTac_Click" />   <!-- Add only to UH-1N -->       &nb

Contextmenu in asp.net website????

  
hey everyonemy problem is dat..i want to add a contextmenu in my website..is there any way to do dat???thanks in advanceAryan

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

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  
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