Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

dashingsidds

@dashingsidds
About
Posts
81
Topics
32
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Creating an instance of SelectionChangedEventArgs in wpf
    D dashingsidds

    Hi Pete thanks for your answer. This looks good. Just 1 question. Say I have a listview with 5 items in it and that the 2nd item is selected then "addedItems" is the 2nd item and "removedItems" are the rest of the 4 items. Am I right on this part? Regards, Samar

    WPF csharp wpf help

  • Creating an instance of SelectionChangedEventArgs in wpf
    D dashingsidds

    Hi Pete, The link you have provided gives just a general information on "SelectionChangedEventArgs" class. Also even if I create a method as you have told still i would need to initialize the class somewhere in the said method, right? Or maybe i am not able to understand what you are trying to say. Can you please give me a small code snippet of the functionality you mentioned? Thanks for your valuable time here. Regards, Samar

    WPF csharp wpf help

  • Creating an instance of SelectionChangedEventArgs in wpf
    D dashingsidds

    hi Pete, I cannot pass null to the parameter because i am doing something with e in inside the handler. Sorry to have not mentioned it here. Regards, Samar

    WPF csharp wpf help

  • Creating an instance of SelectionChangedEventArgs in wpf
    D dashingsidds

    Hi Experts, I have a user control which is having a listview inside it. The SelectionChanged event of this list view is handled inside the user control. The code for the same is as follows:

        private void lstvMyView\_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {...}
    

    I want to call this handler again from some other place inside the user control. So to call this handler i need the "SelectionChangedEventArgs" there. When I am trying to create the instance of "SelectionChangedEventArgs", i am unable to understand what should I pass as parameters to the constructor of "SelectionChangedEventArgs". The place from where I am suppose to call this handler does not add or remove any items in the listview. It just navigates in the items in the listview thereby changing the selectedindex of the listview. I am trying to do something like this. The below code is obviously incorrect.

    lstvMyView_SelectionChanged(_lstvMyView, new SelectionChangedEventArgs());

    Please Help! Thanks in Advance! Regards, Samar

    modified on Wednesday, September 29, 2010 4:42 AM

    WPF csharp wpf help

  • Unable to set focus to datepicker using attached property in wpf
    D dashingsidds

    Hi Experts, I have a custom datepicker with me and i am trying to set focus to this using attached property. I have the toolkit version 3.5.50211.1 which was released on Feb 2010. The focus is working fine when i do DatePicker.Focus(); in my code. My custom datepicker code is as follows: -- My DatePicker

    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Windows.Controls;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Data;
    using System.ComponentModel;
    using System.Windows.Controls.Primitives;

    namespace Guardian.PAS.PASFramework.UI.WPF
    {
    public class PASDatePicker : DatePicker
    {
    #region Attached Property

        /// <summary>
        /// Get of IsFocus Property.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool GetIsFocus(DependencyObject obj)
        {
            return (bool)obj.GetValue(IsFocusProperty);
        }
    
        /// <summary>
        /// Set of IsFocus Property.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="value"></param>
        public static void SetIsFocus(DependencyObject obj, bool value)
        {
            obj.SetValue(IsFocusProperty, value);
        }
    
    
        public static readonly DependencyProperty IsFocusProperty =
                DependencyProperty.RegisterAttached(
                 "IsFocus", typeof(bool), typeof(PASDatePicker),
                 new UIPropertyMetadata(false, OnIsFocusPropertyChanged));
    
        /// <summary>
        /// Property change event of IsFocused.
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnIsFocusPropertyChanged(DependencyObject d,
                DependencyPropertyChangedEventArgs e)
        {
            var uie = (UIElement)d;
            if ((bool)e.NewValue)
            {
                // Don't care about false values. 
                (uie as PASDatePicker).Focus();
            }
        }
        #endregion
    }
    

    }

    I am using this datepicker in my code and tryin

    WPF csharp wpf linq design announcement

  • Combo box inside a user control disappears when style is applied
    D dashingsidds

    Oh... Then what should i write in the control template to show the current combo box as it is??? I am a little weak in xaml..!! :)

    WPF wpf csharp database dotnet com

  • Combo box inside a user control disappears when style is applied
    D dashingsidds

    Hi, I am trying to apply a style to a combo box but instead of getting applied the combo box itself disappears. Please check the following xaml code for user control.

    <UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
    x:Class="Guardian.PAS.PASFramework.UI.WPF.PASComboBox"
    xmlns:local="clr-namespace:Guardian.PAS.PASFramework.UI.WPF"
    Height="26" Width="100" VerticalAlignment="Center" >
    <UserControl.Resources>
    <Style x:Key="comboBoxStyle" TargetType="{x:Type local:PASCustomComboBox}">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type local:PASCustomComboBox}">
    <ControlTemplate.Triggers>
    <Trigger Property="local:PASCustomComboBox.IsEnabled" Value="false">
    <Setter Property="Background" Value="Red"/>
    </Trigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </UserControl.Resources>
    <Canvas Name="canvas" Height="23" Width="Auto" VerticalAlignment="Center">
    <Label Height="23" Name="lblCaption" Width="20" VerticalAlignment="Center">aaa</Label>
    <local:PASCustomComboBox Height="23" x:Name="cmbComboBoxControl" VerticalAlignment="Center" Width="50"
    IsEditable="True" Style="{StaticResource comboBoxStyle}">
    </local:PASCustomComboBox>
    <Button Height="23" Name="btnSearch" Width="25" Click="btnSearch_Click" Visibility="Collapsed"
    VerticalAlignment="Center">...</Button>
    <Label Height="23" Name="lblDescription" VerticalAlignment="Center" Width="20" Foreground="Blue">

        </Label>
        
    </Canvas>
    

    </UserControl>

    Here PASCustomComboBox is a class which inherites from combo box.

    public class PASCustomComboBox : ComboBox
    {
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            if (e.Key == Key.Down || e.Key == Key.Up)
            {
    
    WPF wpf csharp database dotnet com

  • Adding custom routed event of user control to xaml of a window in wpf
    D dashingsidds

    Hi All, I am able to solve this problem of mine. The link given here explain it. Just to keep it brief i did it using something similar to the following lines of code.

    <c:MyUserControl local:CommandBehavior.RoutedEventName="MyCustomClick"
    local:CommandBehavior.TheCommandToRun="{Binding MyViewModelCommand}"/>

    CommandBehavior is a class given in the link above. Thanks everyone for giving in your valuable time. Regards, Samar

    WPF wpf csharp css wcf com

  • Adding custom routed event of user control to xaml of a window in wpf
    D dashingsidds

    Hi Experts, I am little new to Command binding so this might be a trivial question to many. I know that we can add Command bindings in xaml of a window and give its correspondng property in viewmodel. This viewmodel will be given to the DataContext of the window. Something like the following --app.xaml.cs

    mainWindow.DataContext = viewModel;

    -- xaml

    lt;Button Grid.Row="1" HorizontalAlignment="Right" Margin="0,3,18,3" Name="button1" Width="110"
    Command="{Binding LoadCommand}">_Load</Button>

    -- viewmodel

    /// <summary>
    /// Gets the load command.
    /// </summary>
    /// <value>The load command.</value>
    public ICommand LoadCommand
    {
    get
    {
    if (m_LoadCommand == null)
    {
    m_LoadCommand = new RelayCommand(param => CanLoad(), param => Load());
    }

                return m\_LoadCommand;
            }
        }
    

    Here the relaycommand is a class which implements ICommand interface. CanLoad() and Load() are the methods which will get executed for canexecute and execute action of the relaycommand respectively. This is the click event of the button which is handled. I have a user control which has a custom routedevent registered in it and the user control is then used on a window. I am currently adding the event handler explicitly in code.

    //hook up event listeners on the actual UserControl instance
    this.ucCustomEvent1.CustomClick += new RoutedEventHandler(ucCustomEvent_CustomClick);
    //hook up event listeners on the main window (Window1)
    this.AddHandler(UserControlThatCreatesEvent.CustomClickEvent, new RoutedEventHandler(ucCustomEvent_CustomClick));

    I dont want to hook up the routedevent explicitly in code but in the xaml in the similar way as in the button example. I have uploaded the working sample code here for your perusal. Please help! Thanks in advance! Regards, Samar

    WPF wpf csharp css wcf com

  • Updating Observable collection with combo box inside a user control
    D dashingsidds

    Hi Experts, I have a combo box inside a user control and i am trying to update an observable collection with the change event of this combo box. This combo box has a list view inside it. I have added a working example of this scenario so you can copy paste it in your VS IDE. The user control in this example is just a part of the original user control. I have removed the code which are not required. --Customer.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;

    namespace TestMVVM
    {
    class Customer : INotifyPropertyChanged
    {

        public int ID { get; set; }
        public int NumberOfContracts { get; set; }
    
        private string firstName;
        private string lastName;
    
        public string FirstName
        {
            get { return firstName; }
            set
            {
                if (firstName != value)
                {
                    firstName = value;
                    RaisePropertyChanged("FirstName");
    
                }
            }
        }
    
        public string LastName
        {
            get { return lastName; }
            set
            {
                if (lastName != value)
                {
                    lastName = value;
                    RaisePropertyChanged("LastName");
                }
            }
        }
    
        #region PropertChanged Block
        public event PropertyChangedEventHandler PropertyChanged;
    
        private void RaisePropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }
        #endregion
    }
    

    }

    --CustomerHeaderViewModel class

    class CustomerHeaderViewModel
    {
        public ObservableCollection Customers { get; set; }
    
        public void LoadCustomers()
        {
            ObservableCollection customers = new ObservableCollection();
    
            //this is where you would actually call your service
            customers.Add(new Customer { ID = 1, FirstName = "Jim", LastName = "Smith", NumberOfContracts = 23 });
    
            Customers = customers;
        }
    }
    

    -- UCComboBox.xaml User Control

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

    WPF visual-studio csharp wpf linq com

  • observable collection not getting updated on UI change
    D dashingsidds

    Thanks Ian..!!! :)

    WCF and WF csharp css wpf linq com

  • observable collection not getting updated on UI change
    D dashingsidds

    Thank you very much for the insight on WPF. I am a little new to WPF and have the only hands on since i am on this project. I think this did the trick for me. Will remember this and also will remove the unwanted code which you have said. Also sorry to have posted in WCF section. I did not check the forum name before posting this. What do you want me to do on this? Should i copy paste this query to WPF forum now? Please advice.

    WCF and WF csharp css wpf linq com

  • observable collection not getting updated on UI change
    D dashingsidds

    Hi Experts, I am trying to bind an observable collection to a user control but it is not getting updated on user change but it is getting updated when the user control is changed through code. Following is an example i tried. It might be a bit long but it is working so you can copy and paste the code as it is. Please see my question at the end of the post. --Customer.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;

    namespace TestMVVM
    {
    class Customer : INotifyPropertyChanged
    {
    private string firstName;
    private string lastName;

        public string FirstName
        {
            get { return firstName; }
            set
            {
                if (firstName != value)
                {
                    firstName = value;
                    RaisePropertyChanged("FirstName");
    
                }
            }
        }
    
        public string LastName
        {
            get { return lastName; }
            set
            {
                if (lastName != value)
                {
                    lastName = value;
                    RaisePropertyChanged("LastName");
                }
            }
        }
    
        #region PropertChanged Block
        public event PropertyChangedEventHandler PropertyChanged;
    
        private void RaisePropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, 
    

    new PropertyChangedEventArgs(property));
    }
    }
    #endregion
    }
    }

    --UCTextBox.xaml

    <UserControl x:Class="TestMVVM.UCTextBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="40" Width="200">
    <Grid>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="txtTextControl" 
                 VerticalAlignment="Top" Width="120" />
    </Grid>
    

    </UserControl>

    --UCTextBox.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Collectio

    WCF and WF csharp css wpf linq com

  • could not capture down arrow in combobox in wpf
    D dashingsidds

    Hi Guys, I got the answer. The PreviewKeyUp event worked for the down arrow. Thanks anyways for looking into it for me. But can anyone please explain as to y the PreviewKeyDown event did not get fired for down arrow?? Regards, Dhaval

    WCF and WF csharp wpf help

  • could not capture down arrow in combobox in wpf
    D dashingsidds

    Hi Experts, I have a combobox on a window in wpf and i am trying to capture the down arrow key of this combobox but i am not able to do so. The following is the only code i have for the combobox.

    <ComboBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120"
    PreviewKeyDown="comboBox1_PreviewKeyDown" KeyDown="comboBox1_KeyDown" IsEditable="True"/>

    C#

    private void comboBox1\_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
                MessageBox.Show("hi");
        }
    
        private void comboBox1\_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
                MessageBox.Show("hi");
        }
    

    The event is not even hit when i press down arrow key. Please help! Thanks in advance! Regards, Samar

    WCF and WF csharp wpf help

  • Constraints taking either types in generics
    D dashingsidds

    I knew this would come. But my problem here is the class MyClass1 in my case is a .net class and i cannot modify it to make it implement an interface. Thanks for your time kapax5. Regards, Samar

    C# help

  • Constraints taking either types in generics
    D dashingsidds

    Hi Experts, In generics we can give constraints using the "where" clause like

    public void MyGeneric <T>() where T : MyClass1 {...}

    Now if i want the type T to be of type MyClass1 and say an interface IMyInterface then i need to do something like

    public void MyGeneric <T>() where T : MyClass1, IMyInterface {...}

    But I dont know (or maybe it is not possible) if we can create a generic method that can take types which inherits from either of the 2 types. i.e. if any of my other classes inherits from MyClass1 or implements IMyInterface but neither of my class has both then my generic method should work for these classes. I hope I have been clear. Please help! Thanks in advance! Regards, Samar

    C# help

  • Alternative to "DropDownWidth" Property for Combo Box in WPF.
    D dashingsidds

    Hi Experts, I am unable to locate a property similar to WindowsForm "DropDownWidth" Property for the Combo Box in WPF. Is there a work around to achieve this functionality? Please help! Thanks in advance. Regards, Samar P.S.: Just FYI for those who are not aware, "DropDownWidth" Property changes the width of the drop down area. The area when the Combo Box is clicked to show its master contents.

    WCF and WF csharp wpf help question

  • Alternative to "DropDownWidth" Property for Combo Box in WPF.
    D dashingsidds

    Hi Experts, I am unable to locate a property similar to WindowsForm "DropDownWidth" Property for the Combo Box in WPF. Is there a work around to achieve this functionality? Please help! Thanks in advance. Regards, Samar P.S.: Just FYI for those who are not aware, "DropDownWidth" Property changes the width of the drop down area. The area when the Combo Box is clicked to show its master contents.

    modified on Friday, July 30, 2010 2:40 AM

    WPF csharp wpf help question

  • Tab index not working properly with user controls
    D dashingsidds

    Hi Experts, I have a window which is having some objects of a user control. The user control is nothing but a combination of label and textbox. I have set the tabindex property of these objects in certain order but when i run the window that order is not maintained. This is working fine if i use normal wpf controls like the normal textbox or button. Am i missing something? Please help! Thanks in advance! Regards, Samar

    WPF csharp database wpf winforms help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups