Get Data From MenuItem.DataContext?

Dec 15, 2011

I have a context menu on my DataTemplete for a list box, and that menu will contain links to Favourite and Retweet the tweet (the menu item) But I don't know how to get the information about the Tweet in code. I am trying the following Line:

[Code]...

View 3 Replies


ADVERTISEMENT

In A Datacontext Are Inserted Values Not Available Within Datacontext Until After Submitchanges

Mar 18, 2009

I'm going through an XML file of articles and the journalist(s) that wrote them. As we are adding the articles into _Data our datacontext we may come across a journalist that needs adding so we do this: [code] However subsequently we may come across this same journalist again and nothing is returned when we do this: [code] So it uses the code above again to insert the same journalist again.Once all of our inserts are done we do a submitchanges. At this point it has a head fit:INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_ articles_ journalists_journalists'. The conflict occurred in database 'blah', table 'journalists', column 'id'. The statement has been terminated.From looking through the sql generated in sql profiler you can see that it is trying to add some journalists more than once, this will fail as the name must be distinct. The subsequent records that are trying to be inserted with these journalists are failing as the journalist wasn't updated.Surely if I have a collection of journalists, add some to it and then look in my collection I should see all of them and not just the original ones.

View 3 Replies

.net - Make Sure The View Is Rendered Only When The Type Of DataContext Matches Data Template's Target Type?

Dec 10, 2010

<ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding Path={x:Static vmc:clsPersonViewModel.ChildrenPath}, Mode=OneWay}">
<ItemsControl.ItemTemplate>

[Code].....

In the code above, if there are no children (the ChildrenPath property returns NULL), nothing is rendered in the view. In the code below, when ChildrenDataSetPath is NULL the XamDataGrid still gets rendered. How do I achieve the same for a single object (as opposed to a collection) as the datacontext?

<DataTemplate DataType="{x:Type vmb:clsPersonViewModel}">
<igDP:XamDataGrid DataSource="{Binding Path={x:Static vmb:clsPersonViewModel.ChildrenDataSetPath}}">

[Code].....

View 2 Replies

LINQ To SQL DataContext To XML With XSD Schema?

Dec 27, 2010

I have some data in my Linq.DataContext.I had succes in converting it to an XSD - Schema, using the following code:

Dim changeset As System.Data.Linq.ChangeSet = c.GetChangeSet()
Dim objDic As New Dictionary(Of System.Type, List(Of Object))
If Not changeset Is Nothing AndAlso Not changeset.Inserts Is Nothing AndAlso Not

[code].....

View 1 Replies

Overriding Datacontext For View?

Mar 15, 2012

I am setting my viewmodel as datacontext in my xaml but I override it to my view to make few functions work however to achieve the visibility on some grids and I have a property in my VM can I override my datacontext back to my VM? If so how? I have a stackpanel that has datacontext overriden as my grid and within that stackpanel I need to change the datacontext for a button.

View 1 Replies

Get The Attributes Of The <menuitem> Tag?

Dec 10, 2011

How I can get the attributes of the <menuitem> tag?

becuse GetElementsByTagName() and GetAttribute do not work .

View 8 Replies

DataContext - Discard Changes Of Only One Record In Table

Apr 1, 2010

I would like to know if its possible to discard changes of only one record of only one table in datacontext. I use databind to bind my controls on a form. I modify one record at a time. after the modification, the user have to hit save button to validate. But he can hit cancel. I would like that the cancel button discard all the changes that the user has done. Is it possible?

View 3 Replies

Difference Between Using DataContext Class And SqlConnection?

Mar 2, 2012

I asked a question earlier where I was told a simple way to "bind data to objects" is to just run a SqlConnection(connectionString). The response also included a comment saying I could get fancy with L2S and Entity Frameworks, so I looked deeper into those. It seems all you have to do with the DataContext object is point to the database. Why would SqlConnection be a benefit? What is the difference (or pros/cons) of using either one of these? Is one more "standard"? Is one more modern?

View 1 Replies

Two Way Binding LINQ To SQL DataContext Classes

Aug 17, 2009

How to bind a textbox in design view to a LINQ to SQL datacontext class?

View 3 Replies

Understanding ItemsSource And DataContext In A DataGrid?

Jun 14, 2010

UPDATE: See the bottom of this question for what I did to solve the problem.I'm trying to understand how the ItemsSource and DataContext properties work in a Silverlight Toolkit DataGrid. I'm currently working with dummy data and trying to get the data in the DataGrid to update when the value of a combo box changes.

View 2 Replies

MenuItem PopUpMenu Event?

Nov 9, 2009

what code do i add to the following so i can receive an event when one of the menu items is clicked on

Dim menuItems() As MenuItem = New MenuItem() _
{New MenuItem("Make Multi Bay"), _
New MenuItem("-"),

[code]......

View 4 Replies

VS 2005 - Add 2 Shortcut Key For 1 Menuitem?

May 11, 2011

show me how to add 2 shortcut key for 1 menuitem.

View 6 Replies

Check Whether A Linq-to-SQL Object Is Already Attached To A DataContext?

Jun 27, 2011

I have an object that may have been inflated via a plain old DataContext, or may just have been new-ed up with just its .ID property set. There's no way to know for sure. I'm looking to rehydrate the entire object from whatever is in the database. If the object was new-ed up, I can call .Attach() on the table object and refresh from the Data Context with no trouble. But, if the object was already inflated from the DataContext I get the error: "Cannot attach an entity that already exists.". There's no timestamp field or anything like that - just an integer primary key being used to control the rehydration. I'd like to know if there's a way to conditionally attach. Here's the code - it works the way I want it to, but this seems a hackish way to go about it:

' myDC is a shared instance of a vanilla DataContext...
' myObj is an instance of a linqed-up `SomeLinqObject`
Dim tbl = myDC.GetTable(Of SomeLinqObject)()

[Code[,,,,,

View 1 Replies

Setting The DataContext On An Entity Instance After It's Retrieved?

Apr 14, 2011

I'm trying to find a way to have the DataContext available from within Entities.

I want to do something like this:

partial public class MyEntity
public DataContext as MyDataContext
private sub OnLoaded()

[Code]....

View 2 Replies

Setting User Control's DataContext From Code-Behind?

Jul 8, 2009

This should be pretty easy, but it throws VS2008 for a serious loop.I'm trying out WPF with MVVM, and am a total newbie at it although I've been developing for about 15 years, and have a comp. sci. degree. At the current client, I am required to use VB.Net. I have renamed my own variables and removed some distractions in the code below, so please forgive me if it's not 100% syntactically perfect! You probably don't really need the code to understand the question, but I'm including it in cas.

I have a very simple MainView.xaml file:
<Window x:Class="MyApp.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

[code].....

View 3 Replies

Using Same Connection String In A DataContext Constructor And SqlConnection?

Oct 4, 2011

I am preparing to deploy a web service that uses SqlConnection primarily as its means to get to the database, and I am adding some new methods that use a DataContext instead of thatand the default constructor and DBML file would use a connection string refering to my development machine (I believe...)

View 1 Replies

Wpf - DataContext Issues With ListBox After Changes To MainWindow.xaml?

Jun 18, 2012

I am new to WPF and the MVVM design pattern this month, and more than a little out of practice in general. To learn, I've been playing around with textboxes, rectangles, and ways to display them in a window. I began with Ashley Davis' excellent "Simple Drag Selection in WPF" tutorial, which walks through creating a view model for a collection of rectangles, binding a listbox to said collection, and styling the listbox with a canvas, creating a data template for the rectangles, as well as basic "rubber band" selection logic.

I have since built on this tutorial to improve the drag selection so that it behaves much more like selection does in windows explorer, and to allow resizing the rectangles from the corners or edges.All was well until I changed the MainWindow.xaml in an effort to include a column on the side for various buttons and controls, thus moving the "editor surface" grid from inside a 1x1 grid on the main window to a column of a 1x2 grid, moving the data template to the grid's resources (since it will be the only element in the window that needs it). As soon as I did this, subroutines that I wrote which interact with the listbox started misbehaving--rubber band selection no longer works. There's no visual indication that listbox items are being selected (they were highlighted previously), and interrogating listBox.SelectedItems.Count after a drag-selection mouseUp event returns a zero.

After some experimentation, reading many questions on this site and sections of my WPF Unleashed book, and going over the msdn databinding overview, as of this morning I still cannot find my mistake(s). I believe it is a data binding mistake or incorrect data context.Some details about the view models involved:

DataFieldViewModel

...implements INotifyPropertyChanged and exposes properties for its (in this case a rectangle and a textbox) X,Y position, width, height, visibility, and selection status (a way to track it across several rubber band selection operations)

PageViewModel

...implements INotifyPropertyChanged, and has among other things an ObservableCollection of type DataFieldViewModel, called DataFields, and exposes it as a ReadOnly Property.Here's a look at MainWindow.xaml.vb and one of the broken subs:

Namespace EditorUI
'
' The main window of the editor.

[code]....

View 1 Replies

Change HighLight Color MenuItem?

Jan 15, 2012

I have been trying to change the highlight color when the mouse gets on it of the stripmenu..

View 3 Replies

Error On Form With Dropdown Menuitem

Apr 27, 2011

I have used the last month to convert my geneology program from vb6 to vb 2010.All form work as they should, but one form with 3 dropdown menu and a tree for 15 persons and each persons field used to show a new form, where its posible to select some more functions. It possible to se the form on. The tree functions works as they should. Its possible to jump between trees, but if I choose any of the other functions on the form the function is excuted but then I got an error.url...

View 13 Replies

Error On Form With Dropdown Menuitem?

Feb 7, 2012

All form work as they should, but one form with 3 dropdown menu and a tree for 15 persons and each persons field used to show a new form, where its posible to select some morefunctions. It possible to se the form onThe tree functions works as they should. Its possible to jump between trees, but if I choose any of the other functions on the form the function is excuted but then I got an error.

View 11 Replies

MenuItem - Any Way To Create Custom Shortcut?

Feb 23, 2009

Is there any way to create a custom shortcut (one that is not there in the Windows.Forms.Shortcut enumeration) and attach it to a MenuItem. Example I want Ctrl+'+' to be a shortcut for a menuitem. Its not there in the enumeration.

View 6 Replies

MenuItem Checkboxes As Radio Buttons?

Feb 24, 2012

I would like to replace the checkboxes on some of my menuitems with radio buttons so they act mutually exclusive of each other like in device manager. I found a bit of code in the Visual Studio Help that shows how to do this, but I am unsure how to implement the changes. how you access a form's constructor event from within Visual Studio 2010? The code follows:

' This method is called from the constructor of the form to set up the menu
' items.
Public Sub ConfigureMyMenus()

[Code].....

View 9 Replies

Shell From Added MenuItem At Runtime?

Aug 21, 2009

I am building a program which will add items to a menu and launch the appropriate application by clicking the menu item I have added. I have linked to a data file and retrieved the ApplicationID, ApplicationName and ApplicationLink, the later being the location of the EXE file on the selected computer.I believe I can create an EventHandler on the fly to hold the link for each application[code].....


The above will add the Name to the menu, but I can't seem to SHELL the ApplicationLink.

View 5 Replies

Show The ContextMenu On MenuItem Right Click?

Jun 17, 2009

I want to show the contextMenu on MenuItem right click....AS IE favorites....I m able to show the contextMenu when i right click on menu..But the Probs is dat when i right click..Context menu is showing & menu is hidding.......Y so ..I want that when we right clikc on menu..Menu is not hidden..How to do dat..

Private Sub MenuAddToFavorites_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MenuAddToFavorites.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then
ContextMenuFavorites.Show(DirectCast(sender, ToolStripMenuItem).GetCurrentParent.PointToScreen(e.Location))
End If
End Sub

View 1 Replies

Add Menuitem To Ie Edit Control Context Menu

Feb 9, 2010

q1/ how can i add a menuitem to ie edit control context menu? is it a registry setting? q2/ after i've added a menuitem to ie edit control context menus, how can i programmatically edit the text in that edit control when i click my menuitem?

View 3 Replies

MenuItem Control Does Not Work On Windows 7 Machine

Apr 12, 2010

I have an application written in VB.net, compiled and loaded on machines running XP, Vista and Server 2003. When I loaded it on a machine running Windows 7 64 bit, the application runs fine, but one window that has MenuItem controls does not work properly, instead of being able to change items from the collection, that area is just greyed. I loaded the .NET 4.0 framework on it in hopes of some miracle, but it still does not work.

View 1 Replies

Show Context Menu On MenuItem Right Click?

Jun 27, 2009

I drag menu strip on the form..Now I add two menu items...I want that when the user right click on Item1, ContextMenuStrip1 should be shown.

Sir with your code,Contextmenu is shown,when i right click on toolstip..

I have tried the foll. Code

Code: Private Sub Item1ToolStripMenuItem_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Item1ToolStripMenuItem.MouseUp ContextMenuStrip1.Show(DirectCast(sender, ToolStripMenuItem).GetCurrentParent.PointToScreen(e.Location)) End Sub

But the probs is that when i right click on Item1ToolStripMenuItem(drop down menu),context menu is shown...but drop down menu is diappeared,I dont want the drop down menu to be disappeared..

View 1 Replies

Show The ContextMenu On MenuItem Right Click As IE Favorites?

Jun 17, 2009

I want to show the contextMenu on MenuItem right click....AS IE favorites....I m able to show the contextMenu when i right click on menu..But the Probs is dat when i right click..Context menu is showing & menu is hidding.......Y so ..I want that when we right clikc on menu..Menu is not hidden..How to do dat..

Code:
Private Sub MenuAddToFavorites_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MenuAddToFavorites.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then

[code]...

View 1 Replies

Way To Make Clicked Context Menuitem Checked?

Apr 13, 2010

is there a simpler way to make the clicked context menuitem checked? Because e.clickeditem has no checked property.[code]

View 5 Replies

Windows Forms MenuItem Displaying 2 Columns?

May 5, 2011

I am making a change to some code written in vb.net, its a winforms app. The menuitem uses the System.Windows.Forms.MenuItem control. I need to display the values in that drop down menu into 2 columns. It displays a number of items and therefore is too long.I wish to display the items side but side in 2 columns. In C# you can use ToolStripMenuItem which allows you to display multiple columns. Even though ToolStripMenuItem is available in Vb.net its difficult for me in the current app to switch to that tool.

View 3 Replies







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