Search Results

Search found 365 results on 15 pages for 'selecteditem'.

Page 3/15 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • WPF TreeView: How to style selected items with rounded corners like in Explorer

    - by Helge Klein
    The selected item in a WPF TreeView has a dark blue background with "sharp" corners. That looks a bit dated today: I would like to change the background to look like in Explorer of Windows 7 (with/without focus): What I tried so far does not remove the original dark blue background but paints a rounded border on top of it so that you see the dark blue color at the edges and at the left side - ugly. Interestingly, when my version does not have the focus, it looks pretty OK: I would like to refrain from redefining the control template as shown here or here. I want to set the minimum required properties to make the selected item look like in Explorer. Alternative: I would also be happy to have the focused selected item look like mine does now when it does not have the focus. When losing the focus, the color should change from blue to grey. Here is my code: <TreeView x:Name="TreeView" ItemsSource="{Binding TopLevelNodes}" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="BorderBrush" Value="#FF7DA2CE" /> <Setter Property="Background" Value="#FFCCE2FC" /> </Trigger> </Style.Triggers> </Style> </TreeView.ItemContainerStyle> <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type viewmodels:ObjectBaseViewModel}" ItemsSource="{Binding Children}"> <Border Name="ItemBorder" CornerRadius="2" Background="{Binding Background, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" BorderThickness="1"> <StackPanel Orientation="Horizontal" Margin="2"> <Image Name="icon" Source="/ExplorerTreeView/Images/folder.png"/> <TextBlock Text="{Binding Name}"/> </StackPanel> </Border> </HierarchicalDataTemplate> </TreeView.Resources> </TreeView>

    Read the article

  • How to keep an item selected? - ListView

    - by Dodi300
    Hello. I would like to keep an item selected, on a ListView, when the user clicks on a space which has no item. For example, the space below the items, but still on the ListView component. I've change the ListView property "HideSelection" to false, but that only works when the focus is changed to another component; not when the user clicks on the ListView itself. Thanks!

    Read the article

  • CF - MenuItem selection in MainMenu

    - by no9
    Hello. Again i wonder how can i highlight selected item in my MainMenu form. Every time i select an item only the first item is highlighted (always the same). But when a MenuItem is clicked its highlighted untill the Menu reloads. I found "checked" property on MenuItem that would generaly work, but the first item remains highlighted. There is no other properties on menuItem such as background color or selected... Can some one please direct me to the right solution? thanx

    Read the article

  • How do i get the value of the item selected in listview?

    - by user357032
    i thought i would use the position that i had int but when i click on the item in list view nothing happens. Please Help!!!! ListView d = (ListView) findViewById(R.id.apo); ArrayAdapter adapt = ArrayAdapter.createFromResource( this, R.array.algebra, android.R.layout.simple_list_item_1); d.setAdapter(adapt); d.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View view, int position, long id) { if (position == '0'){ Intent intent = new Intent(Algebra.this, Alqv.class); startActivity(intent); } if (position == '2'){ Intent intent1 = new Intent(Algebra.this, qfs.class); startActivity(intent1); } } });

    Read the article

  • ASP.NET lisbox - Selected first item, always

    - by Lijo
    I have a list box which is populated using a dictioanry. When I iterate throught the selected items using the following code, it always show only the first items as selected - even if the first item is not selected. Have you ever encountered this scenario? Could you please help on this? foreach (ListItem item in lstProcessName.Items) { if (item.Selected == true) { selectedNewSales.Add(item.Text); } }

    Read the article

  • How do I get the value of the item selected in ListView?

    - by user357032
    I thought I could use the position int, but when I click on the item in the list view, nothing happens. Please help! ListView d = (ListView) findViewById(R.id.apo); ArrayAdapter adapt = ArrayAdapter.createFromResource(this, R.array.algebra, android.R.layout.simple_list_item_1); d.setAdapter(adapt); d.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == '0') { Intent intent = new Intent(Algebra.this, Alqv.class); startActivity(intent); } if (position == '2') { Intent intent1 = new Intent(Algebra.this, qfs.class); startActivity(intent1); } }); }

    Read the article

  • WPF binding to ComboBox SelectedItem when reference not in ItemsSource.

    - by juharr
    I'm binding the PageMediaSize collection of a PrintQueue to the ItemSource of a ComboBox (This works fine). Then I'm binding the SelectedItem of the ComboBox to the DefaultPrintTicket.PageMediaSize of the PrintQueue. While this will set the selected value to the DefaultPrintTicket.PageMediaSize just fine it does not set the initially selected value of the ComboBox to the initial value of DefaultPrintTicket.PageMediaSize This is because the DefaultPrintTicket.PageMediaSize reference does not match any of the references in the collection. However I don't want it to compare the objects by reference, but instead by value, but PageMediaSize does not override Equals (and I have no control over it). What I'd really like to do is setup a IComparable for the ComboBox to use, but I don't see any way to do that. I've tried to use a Converter, but I would need more than the value and I couldn't figured out how to pass the collection to the ConverterProperty. Any ideas on how to handle this problem. Here's my xaml <ComboBox x:Name="PaperSizeComboBox" ItemsSource="{Binding ElementName=PrintersComboBox, Path=SelectedItem, Converter={StaticResource printQueueToPageSizesConverter}}" SelectedItem="{Binding ElementName=PrintersComboBox, Path=SelectedItem.DefaultPrintTicket.PageMediaSize}" DisplayMemberPath="PageMediaSizeName" Height="22" Margin="120,76,15,0" VerticalAlignment="Top"/> And the code for the converter that gets the PageMediaSize collection public class PrintQueueToPageSizesConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value == null ? null : ((PrintQueue)value).GetPrintCapabilities().PageMediaSizeCapability; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }

    Read the article

  • Distinctly LINQ &ndash; Getting a Distinct List of Objects

    - by David Totzke
    Let’s say that you have a list of objects that contains duplicate items and you want to extract a subset of distinct items.  This is pretty straight forward in the trivial case where the duplicate objects are considered the same such as in the following example: List<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 }; IEnumerable<int> distinctAges = ages.Distinct(); Console.WriteLine("Distinct ages:"); foreach (int age in distinctAges) { Console.WriteLine(age); } /* This code produces the following output: Distinct ages: 21 46 55 17 */ What if you are working with reference types instead?  Imagine a list of search results where items in the results, while unique in and of themselves, also point to a parent.  We’d like to be able to select a bunch of items in the list but then see only a distinct list of parents.  Distinct isn’t going to help us much on its own as all of the items are distinct already.  Perhaps we can create a class with just the information we are interested in like the Id and Name of the parents.  public class SelectedItem { public int ItemID { get; set; } public string DisplayName { get; set; } } We can then use LINQ to populate a list containing objects with just the information we are interested in and then get rid of the duplicates. IEnumerable<SelectedItem> list = (from item in ResultView.SelectedRows.OfType<Contract.ReceiptSelectResults>() select new SelectedItem { ItemID = item.ParentId, DisplayName = item.ParentName }) .Distinct(); Most of you will have guessed that this didn’t work.  Even though some of our objects are now duplicates, because we are working with reference types, it doesn’t matter that their properties are the same, they’re still considered unique.  What we need is a way to define equality for the Distinct() extension method. IEqualityComparer<T> Looking at the Distinct method we see that there is an overload that accepts an IEqualityComparer<T>.  We can simply create a class that implements this interface and that allows us to define equality for our SelectedItem class. public class SelectedItemComparer : IEqualityComparer<SelectedItem> { public new bool Equals(SelectedItem abc, SelectedItem def) { return abc.ItemID == def.ItemID && abc.DisplayName == def.DisplayName; } public int GetHashCode(SelectedItem obj) { string code = obj.DisplayName + obj.ItemID.ToString(); return code.GetHashCode(); } } In the Equals method we simply do whatever comparisons are necessary to determine equality and then return true or false.  Take note of the implementation of the GetHashCode method.  GetHashCode must return the same value for two different objects if our Equals method says they are equal.  Get this wrong and your comparer won’t work .  Even though the Equals method returns true, mismatched hash codes will cause the comparison to fail.  For our example, we simply build a string from the properties of the object and then call GetHashCode() on that. Now all we have to do is pass an instance of our IEqualitlyComarer<T> to Distinct and all will be well: IEnumerable<SelectedItem> list =     (from item in ResultView.SelectedRows.OfType<Contract.ReceiptSelectResults>()         select new SelectedItem { ItemID = item.dahfkp, DisplayName = item.document_code })                         .Distinct(new SelectedItemComparer());   Enjoy. Dave Just because I can… Technorati Tags: LINQ,C#

    Read the article

  • MVVM in Task-It

    As I'm gearing up to write a post about dynamic XAP loading with MEF, I'd like to first talk a bit about MVVM, the Model-View-ViewModel pattern, as I will be leveraging this pattern in my future posts. Download Source Code Why MVVM? Your first question may be, "why do I need this pattern? I've been using a code-behind approach for years and it works fine." Well, you really don't have to make the switch to MVVM, but let me first explain some of the benefits I see for doing so. MVVM Benefits Testability - This is the one you'll probably hear the most about when it comes to MVVM. Moving most of the code from your code-behind to a separate view model class means you can now write unit tests against the view model without any knowledge of a view (UserControl). Multiple UIs - Let's just say that you've created a killer app, it's running in the browser, and maybe you've even made it run out-of-browser. Now what if your boss comes to you and says, "I heard about this new Windows Phone 7 device that is coming out later this year. Can you start porting the app to that device?". Well, now you have to create a new UI (UserControls, etc.) because you have a lot less screen real estate to work with. So what do you do, copy all of your existing UserControls, paste them, rename them, and then start changing the code? Hmm, that doesn't sound so good. But wait, if most of the code that makes your browser-based app tick lives in view model classes, now you can create new view (UserControls) for Windows Phone 7 that reference the same view model classes as your browser-based app. Page state - In Silverlight you're at some point going to be faced with the same issue you dealt with for years in ASP.NET, maintaining page state. Let's say a user hits your Products page, does some stuff (filters record, etc.), then leaves the page and comes back later. It would be best if the Products page was in the same state as when they left it right? Well, if you've thrown away your view (UserControl or Page) and moved off to another part of the UI, when you come back to Products you're probably going to re-instantiate your view...which will put it right back in the state it was when it started. Hmm, not good. Well, with a little help from MEF you can store the state in your view model class, MEF will keep that view model instance hanging around in memory, and then you simply rebind your view to the view model class. I made that sound easy, but it's actually a bit of work to properly store and restore the state. At least it can be done though, which will make your users a lot happier! I'll talk more about this in an upcoming blog post. No event handlers? Another nice thing about MVVM is that you can bind your UserControls to the view model, which may eliminate the need for event handlers in your code-behind. So instead of having a Click handler on a Button (or RadMenuItem), for example, you can now bind your control's Command property to a DelegateCommand in your view model (I'll talk more about Commands in an upcoming post). Instead of having a SelectionChanged event handler on your RadGridView you can now bind its SelectedItem property to a property in your view model, and each time the user clicks a row, the view model property's setter will be called. Now through the magic of binding we can eliminate the need for traditional code-behind based event handlers on our user interface controls, and the best thing is that the view model knows about everything that's going on...which means we can test things without a user interface. The brains of the operation So what we're seeing here is that the view is now just a dumb layer that binds to the view model, and that the view model is in control of just about everything, like what happens when a RadGridView row is selected, or when a RadComboBoxItem is selected, or when a RadMenuItem is clicked. It is also responsible for loading data when the page is hit, as well as kicking off data inserts, updates and deletions. Once again, all of this stuff can be tested without the need for a user interface. If the test works, then it'll work regardless of whether the user is hitting the browser-based version of your app, or the Windows Phone 7 version. Nice! The database Before running the code for this app you will need to create the database. First, create a database called MVVMProject in SQL Server, then run MVVMProject.sql in the MVVMProject/Database directory of your downloaded .zip file. This should give you a Task table with 3 records in it. When you fire up the solution you will also need to update the connection string in web.config to point to your database instead of IBM12\SQLSERVER2008. The code One note about this code is that it runs against the latest Silverlight 4 RC and WCF RIA Services code. Please see my first blog post about updating to the RC bits. Beta to RC - Part 1 At the top of this post is a link to a sample project that demonstrates a sample application with a Tasks page that uses the MVVM pattern. This is a simplified version of how I have implemented the Tasks page in the Task-It application. Youll notice that Tasks.xaml has very little code to it. Just a TextBlock that displays the page title and a ContentControl. <StackPanel>     <TextBlock Text="Tasks" Style="{StaticResource PageTitleStyle}"/>     <Rectangle Style="{StaticResource StandardSpacerStyle}"/>     <ContentControl x:Name="ContentControl1"/> </StackPanel> In List.xaml we have a RadGridView. Notice that the ItemsSource is bound to a property in the view model class call Tasks, SelectedItem is bound to a property in the view model called SelectedItem, and IsBusy is bound to a property in the view model called IsLoading. <Grid>     <telerikGridView:RadGridView ItemsSource="{Binding Tasks}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}"                                  IsBusy="{Binding IsLoading}" AutoGenerateColumns="False" IsReadOnly="True" RowIndicatorVisibility="Collapsed"                IsFilteringAllowed="False" ShowGroupPanel="False">         <telerikGridView:RadGridView.Columns>             <telerikGridView:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" Width="3*"/>             <telerikGridView:GridViewDataColumn Header="Due" DataMemberBinding="{Binding DueDate}" DataFormatString="{}{0:d}" Width="*"/>         </telerikGridView:RadGridView.Columns>     </telerikGridView:RadGridView> </Grid> In Details.xaml we have a Save button that is bound to a property called SaveCommand in our view model. We also have a simple form (Im using a couple of controls here from Silverlight.FX for the form layout, FormPanel and Label simply because they make for a clean XAML layout). Notice that the FormPanel is also bound to the SelectedItem in the view model (the same one that the RadGridView is). The two form controls, the TextBox and RadDatePicker) are bound to the SelectedItem's Name and DueDate properties. These are properties of the Task object that WCF RIA Services creates. <StackPanel>     <Button Content="Save" Command="{Binding SaveCommand}" HorizontalAlignment="Left"/>     <Rectangle Style="{StaticResource StandardSpacerStyle}"/>     <fxui:FormPanel DataContext="{Binding SelectedItem}" Style="{StaticResource FormContainerStyle}">         <fxui:Label Text="Name:"/>         <TextBox Text="{Binding Name, Mode=TwoWay}"/>         <fxui:Label Text="Due:"/>         <telerikInput:RadDatePicker SelectedDate="{Binding DueDate, Mode=TwoWay}"/>     </fxui:FormPanel> </StackPanel> In the code-behind of the Tasks control, Tasks.xaml.cs, I created an instance of the view model class (TasksViewModel) in the constructor and set it as the DataContext for the control. The Tasks page will load one of two child UserControls depending on whether you are viewing the list of tasks (List.xaml) or the form for editing a task (Details.xaml). // Set the DataContext to an instance of the view model class var viewModel = new TasksViewModel(); DataContext = viewModel;   // Child user controls (inherit DataContext from this user control) List = new List(); // RadGridView Details = new Details(); // Form When the page first loads, the List is loaded into the ContentControl. // Show the RadGridView first ContentControl1.Content = List; In the code-behind we also listen for a couple of the view models events. The ItemSelected event will be fired when the user clicks on a record in the RadGridView in the List control. The SaveCompleted event will be fired when the user clicks Save in the Details control (the form). Here the view model is in control, and is letting the view know when something needs to change. // Listeners for the view model's events viewModel.ItemSelected += OnItemSelected; viewModel.SaveCompleted += OnSaveCompleted; The event handlers toggle the view between the RadGridView (List) and the form (Details). void OnItemSelected(object sender, RoutedEventArgs e) {     // Show the form     ContentControl1.Content = Details; }   void OnSaveCompleted(object sender, RoutedEventArgs e) {     // Show the RadGridView     ContentControl1.Content = List; } In TasksViewModel, we instantiate a DataContext object and a SaveCommand in the constructor. DataContext is a WCF RIA Services object that well use to retrieve the list of Tasks and to save any changes to a task. Ill talk more about this and Commands in future post, but for now think of the SaveCommand as an event handler that is called when the Save button in the form is clicked. DataContext = new DataContext(); SaveCommand = new DelegateCommand(OnSave); When the TasksViewModel constructor is called we also make a call to LoadTasks. This sets IsLoading to true (which causes the RadGridViews busy indicator to appear) and retrieves the records via WCF RIA Services.         public LoadOperation<Task> LoadTasks()         {             // Show the loading message             IsLoading = true;             // Get the data via WCF RIA Services. When the call has returned, called OnTasksLoaded.             return DataContext.Load(DataContext.GetTasksQuery(), OnTasksLoaded, false);         } When the data is returned, OnTasksLoaded is called. This sets IsLoading to false (which hides the RadGridViews busy indicator), and fires property changed notifications to the UI to let it know that the IsLoading and Tasks properties have changed. This property changed notification basically tells the UI to rebind. void OnTasksLoaded(LoadOperation<Task> lo) {     // Hide the loading message     IsLoading = false;       // Notify the UI that Tasks and IsLoading properties have changed     this.OnPropertyChanged(p => p.Tasks);     this.OnPropertyChanged(p => p.IsLoading); } Next lets look at the view models SelectedItem property. This is the one thats bound to both the RadGridView and the form. When the user clicks a record in the RadGridView its setter gets called (set a breakpoint and see what I mean). The other code in the setter lets the UI know that the SelectedItem has changed (so the form displays the correct data), and fires the event that notifies the UI that a selection has occurred (which tells the UI to switch from List to Details). public Task SelectedItem {     get { return _selectedItem; }     set     {         _selectedItem = value;           // Let the UI know that the SelectedItem has changed (forces it to re-bind)         this.OnPropertyChanged(p => p.SelectedItem);         // Notify the UI, so it can switch to the Details (form) page         NotifyItemSelected();     } } One last thing, saving the data. When the Save button in the form is clicked it fires the SaveCommand, which calls the OnSave method in the view model (once again, set a breakpoint to see it in action). public void OnSave() {     // Save the changes via WCF RIA Services. When the save is complete, call OnSaveCompleted.     DataContext.SubmitChanges(OnSaveCompleted, null); } In OnSave, we tell WCF RIA Services to submit any changes, which there will be if you changed either the Name or the Due Date in the form. When the save is completed, it calls OnSaveCompleted. This method fires a notification back to the UI that the save is completed, which causes the RadGridView (List) to show again. public virtual void OnSaveCompleted(SubmitOperation so) {     // Clear the item that is selected in the grid (in case we want to select it again)     SelectedItem = null;     // Notify the UI, so it can switch back to the List (RadGridView) page     NotifySaveCompleted(); } Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • ASP.NET RadioButtonList help. If I set a selectedItem, that item doesn't react to SelectedIndexChang

    - by Hcabnettek
    Hi Guys, I have a RadioButtonList on my web form. I have tried two different means to set the selected item. I have tried in the markup, and in code, like the Page_Load event. It sets and displays correctly. My problem is that the selected radio button no longer responds to the SelectedIndexChanged event. The other items works as expected and if I remove the code that sets the selectedItem, then the radio button works as expected. Is there any way I can set a radio button through code, and it still behaves as I would expect. I am guessing, if u force a button to be selected, then it doesn't change. Does anyone know how to rememdey this so I can default select it, but still have it behave the way I want? <asp:RadioButtonList ID="rblPaymentType" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" RepeatLayout="Flow"> <asp:ListItem Value="benefit" Text="Benefit" Selected="True"/> <asp:ListItem Value="expense" Text="Expense" /> </asp:RadioButtonList> This lives inside an ascx which I have an event for public delegate void SwitchBenefitTypeHandler(object sender, EventArgs e); public event SwitchBenefitTypeHandler SwitchedBenefit; protected void Page_Load(object sender, EventArgs e) { WireEvents(); } private void WireEvents() { rblPaymentType.SelectedIndexChanged += (sender, args) => SwitchedBenefit(sender, args); } Then on the aspx, I wire a handler function to that event. if (header is PaymentHeader) (header as PaymentHeader).SwitchedBenefit += (paymentForm as PaymentBaseControl).Update; Finally the handler function public override void Update(object sender, EventArgs e) { if (sender is RadioButtonList) { IsExpense = (sender as RadioButtonList).SelectedValue == "expense"; UpdateCalcFlag(); UpdateDropDownDataSources(); UpdatePaymentTypeDropDown(); ResetBenefitLabels(); FormatAmountTextBox(); } } I hope that's enough code. Everything works great when I don't set the SelectedItem in the RadioButtonList but I need it set. Here's a link to someone with the same problem. It is ASP.NET AJAX related. Click Here Thanks, ~ck in San Diego

    Read the article

  • How do I bind a Listview SelectedItem to a Textbox using the TwoWay mode?

    - by Nick U
    I am very new to WPF and testing some things that I would like to include in an application that I will be working on. I have a 2 row ListView (bound to a textbox) with the names Scott Guthrie and Jon Skeet in it. I am trying to select "Scott Guthrie" in the ListView and have it populate the TextBox. I want to be able to edit the text and tab off and have the ListView updated. Edit:I removed the code since that really didn't add anything to the question.

    Read the article

  • WPF DataGrid - Can't Use Mouse To Scroll Because Of Drag Drop

    - by OrPaz
    Hello, I am using a datagrid that is allowing to drag its rows. My problem is that when i try to scroll down on my grid using the mouse on the side scroller, i get the 'no enterance' sign that means that "drag and drop is not allowed here, dude...". How can i modify my drag and drop function to recognize that this is not a drag and drop action, but a scroll mouse action? private new void MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPosition = e.GetPosition(GridUC); Object selectedItem = GridUC.SelectedItem; if (selectedItem == null) return; DragDropContainerObject ddObject = new DragDropContainerObject(typeof(Actor), selectedItem); DataGridRow container = (DataGridRow)GridUC.ItemContainerGenerator.ContainerFromItem(selectedItem); if (container != null) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(container, ddObject, DragDropEffects.Link); } } }

    Read the article

  • Problem with Binding Multiple Objects on WPF

    - by Diego Modolo Ribeiro
    Hi, I'm developing a user control called SearchBox, that will act as a replacer for ComboBox for multiple records, as the performance in ComboBox is low for this scenario, but I'm having a big binding problem. I have a base control with a DependencyProperty called SelectedItem, and my SearchControl shows that control so that the user can select the record. The SearchControl also has a DependencyProperty called SelectedItem on it, and it is being updated when the user selects something on the base control, but the UI, wich has the SearchControl, is not being updated. I used a null converter so that I could see if the property was updating, but it's not. Below is some of the code: This is the UI: <NectarControles:MaskedSearchControl x:Name="teste" Grid.Row="0" Grid.Column="1" Height="21" ItemsSource="{Binding C001_Lista}" DisplayMember="C001_Codigo" Custom:CustomizadorTextBox.CodigoCampo="C001_Codigo" ViewType="{x:Type C001:C001_Search}" ViewModelType="{x:Type C001_ViewModel:C001_ViewModel}" SelectedItem="{Binding Path=Instancia.C001_Holding, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DebuggingConverter}}"> </NectarControles:MaskedSearchControl> This is the relevante part of the SearchControl: Binding selectedItemBinding = new Binding("SelectedItem"); selectedItemBinding.Source = this.SearchControlBase; selectedItemBinding.Mode = BindingMode.TwoWay; selectedItemBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; this.SetBinding(SelectedItemProperty, selectedItemBinding); ... public System.Data.Objects.DataClasses.IEntityWithKey SelectedItem { get { return (System.Data.Objects.DataClasses.IEntityWithKey)GetValue(SelectedItemProperty); } set { SetValue(SelectedItemProperty, value); if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem")); } } Please someone help me... Tks...

    Read the article

  • Problem updating values in combobox in vb.net

    - by user225269
    I have this code, but I have a problem. When I update but do not really made any changes to the value and press the update button, the data becomes null. And it will seem that I deleted the value. I've taught of a solution, that is to add both combobox1.selectedtext and combobox1.selecteditem to the function. But it doesn't work. combobox1.selecteditem is working when you try to alter the values when you update. But will save a null value when you don't alter the values using the combobox combobox1.selectedtext will save the data into the database even without altering. But will not save the data if you try to alter it. -And I incorporated both of them, but still only one is performing, and I think it is the one that I added first: Dim shikai As New Updater Try shikai.id = TextBox1.Text shikai.fname = TextBox2.Text shikai.mi = TextBox3.Text shikai.lname = TextBox4.Text shikai.ad = TextBox5.Text shikai.contact = TextBox9.Text shikai.year = ComboBox1.SelectedText shikai.section = ComboBox2.SelectedText shikai.gender = ComboBox3.SelectedText shikai.religion = ComboBox4.SelectedText shikai.year = ComboBox1.SelectedItem shikai.section = ComboBox2.SelectedItem shikai.gender = ComboBox3.SelectedItem shikai.religion = ComboBox4.SelectedItem shikai.bday = TextBox6.Text shikai.updates() MsgBox("Successfully updated!") Please help, what would be a simple workaround to solve this problem?

    Read the article

  • WPF: Master - detail view with two datagrids and in MVVM

    - by EV
    Hi, I'm trying to write a master - detail control that consists of a master datagrid and the detail datagrid. My scenario was following - I used the SelectedItem and bound it to a property in ModelView. The problem is - the SelectedItem in ViewModel is never used, so I can't get the information which item is selected in a master datagrid and cannot fetch the data for thos selection. The code is below: <toolkit:DataGrid ItemsSource="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected" SelectedItem="{Binding SelectedItemHandler, Mode=TwoWay}"></toolkit:DataGrid> And in ViewModel private CustomerObjects _selectedItem; public CustomerObjects SelectedItemHandler { get { return _selectedItem; } set { OnPropertyChanged("SelectedItem"); } } The code in SelectedItemHandler is never used. What could be the problem? Should I use another approach to create master - detail in MVVM?

    Read the article

  • WPF - simple relative path - FindAncestor

    - by user309392
    In the XAML below the ToolTip correctly binds to RelativeSource Self. However, I can't for the life of me work out how to get the TextBlock in the commented block to refer to SelectedItem.Description <Controls:RadComboBoxWithCommand x:Name="cmbPacking" Grid.Row="2" Grid.Column="5" ItemsSource="{Binding PackingComboSource}" DisplayMemberPath="DisplayMember" SelectedValuePath="SelectedValue" SelectedValue="{Binding ElementName=dataGrid1, Path=SelectedItem.PackingID}" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Description}" IsSynchronizedWithCurrentItem="True" Style="{StaticResource comboBox}"> <!-- <Controls:RadComboBoxWithCommand.ToolTip>--> <!-- <TextBlock Text="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Description}" TextWrapping="Wrap" Width="50"/>--> <!-- </Controls:RadComboBoxWithCommand.ToolTip>--> </Controls:RadComboBoxWithCommand> I would appreciate any suggestions Thanks - Jeremy

    Read the article

  • Unable to understand "A field initializer cannot reference the nonstatic field" Error?

    - by Subhen
    Hi, I am getting the error "A field initializer cannot reference the nonstatic field", While My code is as below: Object selectedItem = PageVariables.slectedItemData; MyClass selectedItems = (MyClass)selectedItem; But the same thing works if assign the value at the constructor or in a different method , like below: public partial class MusicPlayer : Page { Object selectedItem = PageVariables.slectedItemData; public MusicPlayer() { InitializeComponent(); MyClass selectedItems = (MyClass)selectedItem; } } I am just trying to understand what is the difference, Why it is looking for a static varaible declaration(in 1st case) while doesn't look for it while in a constructor or a different method!!!

    Read the article

  • How do you keep the text selection on a DataGridView?

    - by fneep
    I'm running C# 2.0, and I've written an application with a DataGridView in virtualmode and a TreeView in the same form, but in different panels of a SplitContainer. My application has a "find all" function that finds all instances of a certain string, and adds them as the child nodes to a new node to the TreeView (it's a tree view because you can have multiple search results by having different root nodes). That idea is that when you click on one of those search results in the TreeView, that it would select the specific text of that result in the DataGridView (Virtually the same as Notepad++'s find all function) When I click on the TreeView, it does set the selected cell of the DataGridView and highlight the specific text, but it loses that specific text selection instantly (but keeps the cell selection) because by clicking on the TreeView the DataGridView loses focus. Here's the code for the AfterSelect of the TreeView: private void Tree_Results_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Level > 0) { SearchResult SelectedItem = (SearchResult)Tree_Results.SelectedNode.Tag; DataViewMain.CurrentCell = DataViewMain[SelectedItem.TypeIndex, SelectedItem.LineIndex]; DataViewMain.BeginEdit(false); DataGridViewTextBoxEditingControl SelectionData = (DataGridViewTextBoxEditingControl)DataViewMain.EditingControl; SelectionData.SelectionStart = SelectedItem.HighlightStart; SelectionData.SelectionLength = SelectedItem.HightlightLength; } } If the DataGridView were a text box I could possibly set HideSelection to false, but DataGridViews have no such property (and changing the Hide Selection for the EditingControl does nothing) Any ideas? I'm receptive to a different control instead of a TreeView that would allow my DataGridView to retain focus.

    Read the article

  • Why Can't I store XML in ASP.NET ListBox Value?

    - by mcass20
    Hello, Why does this work: ListItem item = new ListItem(); string value = lstAvailExtPropsToFilter.SelectedItem.Text +" = "+ txtExtPropToFilter.Text; string text = lstAvailExtPropsToFilter.SelectedItem.Text + " = " + txtExtPropToFilter.Text; item.Text = text; item.Value = value; lstExtPropsToFilter.Items.Add(item); But not this: ListItem item = new ListItem(); string value = string.Format("<key>{0}</key><value>{1}</value>", lstAvailExtPropsToFilter.SelectedItem.Text, txtExtPropToFilter.Text); string text = lstAvailExtPropsToFilter.SelectedItem.Text + " = " + txtExtPropToFilter.Text; item.Text = text; item.Value = value; lstExtPropsToFilter.Items.Add(item);

    Read the article

  • Control Parameters and DropDownList Text

    - by Bunch
    This is something that I rarely need to do, grab a DropDownList’s selected item’s text for use in a datasource’s ControlParameter. To allow for this use SelectedItem.Text instead of the more common SelectedValue for the PropertyName. <asp:ControlParameter ControlID="ddlStuff" Name="stuffName" Type="String" PropertyName="SelectedItem.Text" /> The reason for using this is for text comparison. On rare occasions you may need to check the text against a list where the SelectedValue just does not help. Technorati Tags: ASP.Net

    Read the article

  • Task-It Webinar - Source Code

    Last week I presented a webinar called "Building a real-world application with RadControls for Silverlight 4". For those that didn't get to see the webinar, you can view it here: Building a read-world application with RadControls for Silverlight 4 Since the webinar I've received several requests asking if I could post the source code for the simple application I showed demonstrating some of the techniques used in the development of Task-It, such as MVVM, Commands and Internationalization. This source code is now available for downloadhere. After downloading the source: Extract it to the location of your choice on your hard-drive Open the solution Right-click ModuleProject.Web and selecte 'Set as StartUp Project'. Right-click ProjectTestPage.aspx and selected 'Set as Start Page' Create a database in SQL Server called WebinarProject. Navigate to the Database folder under the WebinarProject directory and run the .sql script against your WebinarProject database. The last two steps are necessary only for the Tasks page to work properly (using WCF RIA Services). Now some notes about each page: Code-behind This is not the way I recommend coding a line-of-business application in Silverlight, but simply wanted to show how the code-behind approach would look. Command This page introduces MVVM and Commands. You'll notice in the XAML that the Command property of theRadMenuItem and the Button are both bound to a SaveCommand. That comes from the view model. If you look in the code- behind of the user control you'll see that an instance of a CommandViewModel is instantiated and set as the DataContext of the UserControl.There is also a listener for the view model's SaveCompleted event. When this is fired, it tells the view (UserControl) to display the MessageBox. Internationalization This sample is similar to the previous one, but instead of using hard-coded strings in the UI, the strings are obtained via binding toview model properties. The view model gets the strings from the .resx files (Strings.resx or Strings.de.resx) under Assets/Resources. If you uncomment the call to ShowGerman() in App.xaml.cs's Application_Startup method and re-run the application, you will see the UI in German. Note that this code, which sets the CurrentCulture and CurrentUICulture on the current thread to "de" (German) is for testing purposes only. RadWindow Once again, very similar to the previous example.The difference is that we are now using a RadWindow to display the 'Saved' message instead of a MessageBox. The advantage here is that we do not have to hold on to a reference to the view model in our code behind so that we can get the 'Saved' message from it. The RadWindow's DataContext is now also bound to the view model, so within its XAML we can bind directly to properties in the view model. Much nicer, and cleaner. One other thing I introduced in this example is the use of spacer Rectangles. Rather than setting a width and/or height on the rectangles for spacing, I am now referencing a style in my ResourceDictionary called StandardSpacerStyle. I like doing this better than using margins or padding because now I have a reusable way to create space between elements, the Rectangle does not show (because I have not set its Fill color), and I can change my spacing throughout the user interface in one place if I'd like. Tasks This page is quite a bit different than the other four. It is a very simple, stripped-down version of the Tasks page in the Task-It application. The Tasks.xaml UserControl has a ContentControl, and the Content of that control is set based on whether we are looking at the list of tasks or editing a task. So it displays one of two child UserControls, which are called List and Details. List has the RadGridView, Details has the form. In the code-behind of the Tasks UserControl I am once again setting its DataContext to a view model class. The nice thing is, whichever child UserControl is being displayed (List or Details) inherits its DataContext from its parent control (Tasks), so I do not have to explicitly set it. The List UserControl simply displays a RadGridView whose ItemsSource is bound to a property in the view model called Tasks, and its SelectedItem property is bound to a property in the view model called SelectedItem. The SelectedItem binding must be TwoWay so that the view is notified when the SelectedItem changes in the view model, and the view model is notified when something changes in the view (like when a user changes the Name and/or DueDate in the form). You'll also notice that the form's TextBox and RadDatePicker are also TwoWay bound to the SelectedItem property in the view model. You can experiment with the binding by removing TwoWay and see how changes in the form do not show up in the RadGridView. So here we have an example of two different views (List and Details) that are both bound to the same view model...and actually, so is the Tasks UserControl, so it is really three views. WCF RIA Services By the way, I am using WCF RIA Services to retrieve data for the RadGridView and save the data when the user clicks the Save button in the form. I created a really simple ADO.NET Entity Data Model in WebinarProject.Web called DataModel.edmx. I also created a simple Domain Data Service called DataService that has methods for retrieving data, inserting, updating and deleting. However I am only using the retrieval and update methods in this sample. Note that I do not currently have any validation in place on the form, as I wanted to keep the sample as simple as possible. Wrap up Technically, I should move the calls to WCF RIA Services out of the view model and put them into a separate layer, but this works for now, and that is a topic for another day! Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • ajax tabcontainer with button postback problem

    - by yousof
    I have a dropdownlist in my web page and two command buttons and a tabcontainer. The tabcontainer does not appear after the load of page according to my code. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then TabContainer1.Visible = False If CtvAct.GetRecords("Fill_RequestTypeTb") = True Then ReqTypeCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLRequestType").DefaultView ReqTypeCmbo.DataTextField = "RequestTypeName" ReqTypeCmbo.DataValueField = "RequestTypeId" ReqTypeCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??? ????? --" itm.Value = "-1" itm.Selected = True ReqTypeCmbo.Items.Insert(0, itm) ReqTypeCmbo.SelectedIndex = 0 End If End If End Sub Protected Sub PrntCmd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PrntCmd.Click TextBox6.Text = "gggg" End Sub Protected Sub ReqTypeCmbo_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ReqTypeCmbo.SelectedIndexChanged If ReqTypeCmbo.SelectedItem.Text = "????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 0 OwnerDataPnl.Enabled = True AttornyDataPnl.Enabled = True BaseDataPnl.Enabled = True RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = False ' Panel1.Visible = False '?????? ?????? ??????? ???????? REstOfficeAddrTxt.Enabled = True REstOffIdeIssuedPlaceTxt.Enabled = True REstOffIdentityNameTxt.Enabled = True REstOffIdentityNumberTxt.Enabled = True REstOffIdentityStartDateTxt.Enabled = True REstOffMobileTxt.Enabled = True REstOffNameTxt.Enabled = True REstOffPhoneTxt.Enabled = True OwnerShipNumberTxt.Enabled = True OwnerShipDateTxt.Enabled = True OwnerShipIssuedPlaceTxt.Enabled = True SerailTxt.Enabled = True RequestIdTxt.Enabled = True RequestDateTxt.Enabled = True RenwDataPnl.Visible = True '''' If CtvAct.GetRecords("Fill_NationalityTb") = True Then OwnrNationCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLNationality").DefaultView OwnrNationCmbo.DataTextField = "NationName" OwnrNationCmbo.DataValueField = "NationId" OwnrNationCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??????? --" itm.Value = "-1" itm.Selected = True OwnrNationCmbo.Items.Insert(0, itm) OwnrNationCmbo.SelectedIndex = 0 End If If CtvAct.GetRecords("Fill_ActivityTb") = True Then AcivityCombo.DataSource = CtvAct.MainDataset.Tables("tbOLActivity").DefaultView AcivityCombo.DataTextField = "ActivityName" AcivityCombo.DataValueField = "ActivityId" AcivityCombo.DataBind() AcivityCombo.SelectedIndex = -1 Dim itm As New ListItem itm.Text = "-- ??? ?????? --" itm.Value = "-1" itm.Selected = True AcivityCombo.Items.Insert(0, itm) AcivityCombo.SelectedIndex = 0 End If 'If CtvAct.GetRecords("Fill_ActivityTb") = True Then ' DropDownList2.DataSource = CtvAct.MainDataset.Tables("tbOLActivity").DefaultView ' DropDownList2.DataTextField = "ActivityName" ' DropDownList2.DataValueField = "ActivityId" ' DropDownList2.DataBind() 'AcivityCombo.Visible = True ' LbCon.Text = CtvAct.Prt 'End If AttronayNationCmbo.SelectedIndex = -1 If CtvAct.GetRecords("Fill_NationalityTb") = True Then AttronayNationCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLNationality").DefaultView AttronayNationCmbo.DataTextField = "NationName" AttronayNationCmbo.DataValueField = "NationId" AttronayNationCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??????? --" itm.Value = "-1" itm.Selected = True AttronayNationCmbo.Items.Insert(0, itm) AttronayNationCmbo.SelectedIndex = 0 ' LbCon.Text = CtvAct.Prt End If If CtvAct.GetRecords("Fill_LocationTb") = True Then LocationIdCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLLocation").DefaultView LocationIdCmbo.DataTextField = "LocationName" LocationIdCmbo.DataValueField = "LocationId" LocationIdCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ?????? --" itm.Value = "-1" itm.Selected = True LocationIdCmbo.Items.Insert(0, itm) LocationIdCmbo.SelectedIndex = 0 ' LbCon.Text = CtvAct.Prt End If '''''''''''''''''''''''''''''''' con = New SqlConnection(CtvAct.Connection_String()) CmdActivty = con.CreateCommand CmdActivty.CommandText = "SELECT ActivityId FROM tbOLStoreActivty" DaActivity.SelectCommand = CmdActivty DaActivity.Fill(DsActivity, "tbOLStoreActivty") ActivityGV.DataSource = DaActivity ActivityGV.DataMember = "tbOLStoreActivty" AcivityCombo.DataSource = ds.Tables(0) AcivityCombo.DataTextField = "ename" AcivityCombo.DataValueField = "eid" AcivityCombo.DataBind() ''''''''''''''''''''''''''''' LbCon.Text = CtvAct.Prt ElseIf ReqTypeCmbo.SelectedItem.Text = "?????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = True AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False RenwDataPnl.Visible = True AddActivtyPnl.Visible = False NewOwnerDataPnl0.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = False '?????? ?????? ??????? ???????? REstOfficeAddrTxt.Enabled = False REstOffIdeIssuedPlaceTxt.Enabled = False REstOffIdentityNameTxt.Enabled = False REstOffIdentityNumberTxt.Enabled = False REstOffIdentityStartDateTxt.Enabled = False REstOffMobileTxt.Enabled = False REstOffNameTxt.Enabled = False REstOffPhoneTxt.Enabled = False OwnerShipNumberTxt.Enabled = False OwnerShipDateTxt.Enabled = False OwnerShipIssuedPlaceTxt.Enabled = False SerailTxt.Enabled = True RequestIdTxt.Enabled = True RequestDateTxt.Enabled = True ''''''''' ElseIf ReqTypeCmbo.SelectedItem.Text = "??? ?????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = True AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "????? ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = True LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "????? ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = True LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "??? ???? / ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = True FinishLicePnl.Visible = False LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "??? ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 0 OwnerDataPnl.Enabled = True AttornyDataPnl.Enabled = True BaseDataPnl.Enabled = True RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = True End If End Sub If I press any button after page load the button work very selecting any item from dropdownlist make the tabcontainer appear but after the tabcontainer appear, the buttons does not work (postback) how can I solve these problems

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >