Click here to Skip to main content
15,881,281 members
Home / Discussions / WPF
   

WPF

 
QuestionTrouble with MultiTrigger and IsMouseOver property Pin
t2b18-Nov-13 10:28
t2b18-Nov-13 10:28 
QuestionScroll Bar is not showing Pin
Ashfaque Hussain18-Nov-13 1:56
Ashfaque Hussain18-Nov-13 1:56 
AnswerRe: Scroll Bar is not showing Pin
t2b19-Nov-13 1:22
t2b19-Nov-13 1:22 
GeneralRe: Scroll Bar is not showing Pin
Ashfaque Hussain19-Nov-13 2:30
Ashfaque Hussain19-Nov-13 2:30 
GeneralRe: Scroll Bar is not showing Pin
t2b19-Nov-13 19:57
t2b19-Nov-13 19:57 
QuestionDisplaying border after adding Opacity mask for the image Pin
gourav852412-Nov-13 20:31
gourav852412-Nov-13 20:31 
AnswerRe: Displaying border after adding Opacity mask for the image Pin
RedDk16-Nov-13 11:00
RedDk16-Nov-13 11:00 
QuestionCombobox data wont update WPF MVVM Pin
LiquidHolic12-Nov-13 16:18
LiquidHolic12-Nov-13 16:18 
I have 2 pages (User and UserListing) When I Add new user on User Page then change page to UserListing Page the ComboBoxUser on UserListing Page wont update automatically. Any Idea to solve this ?

this is my code User.cs
C#
public class User : INotifyPropertyChanged
{
    string _firstName;
    public string FirstName {
        get { return _firstName; }
        set { 
            _firstName = value;
            OnPropertyChanged("FirstName");
            OnPropertyChanged("FullName");
        }
    }

    string _lastName;
    public string LastName {
        get { return _lastName; }
        set { 
            _lastName = value;
            OnPropertyChanged("LastName");
            OnPropertyChanged("FullName");
        }
    }

    public string FullName
    {
        get { return string.Format("{0} {1}", FirstName, LastName); }
    }

    int _gender;
    public int Gender {
        get { return _gender; }
        set { 
            _gender = value;
            OnPropertyChanged("Gender");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged(string name)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(name));
        }
    }
}


UserListingViewModel.cs
C#
public class UserListingViewModel : INotifyPropertyChanged
{
    public UserListingViewModel()
    {
        LoadDataUser();
    }

    public void LoadDataUser()
    {
        ComboUserData = new ObservableCollection<User>();

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[
            "dLondre.Properties.Settings.CSLONDRE"].ConnectionString);

        string str = "";
        str += "SELECT userid,firstname + ' ' + lastname as name FROM [user] ";

        SqlCommand com = con.CreateCommand();
        com.CommandText = str;

        try
        {
            con.Open();
            SqlDataReader sdr = com.ExecuteReader();
            while (sdr.Read())
            {
                ComboUserData.Add(new User { UserID = (string)sdr["userid"], FirstName = (string)sdr["name"]});
            }

            com.Dispose();
            con.Close();
            con.Dispose();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }


    ObservableCollection<User> _comboUserData;
    public ObservableCollection<User> ComboUserData
    {
        get
        {
            if (_comboUserData == null)
                _comboUserData = new ObservableCollection<User>();
            return _comboUserData;
        }
        set
        {
            if (value != _comboUserData)
                _comboUserData = value;
            OnPropertyChanged("ComboUserData");
        }
    }

    User _user;
    public User SelectedUserID
    {
        get { return _user; }
        set
        {
            _user = value;
            OnPropertyChanged("SelectedUserID");
        }
    }
}


XAML
XML
<ComboBox x:Name="DDUserId" 
     Width="140" 
     DisplayMemberPath="FirstName" 
     IsSynchronizedWithCurrentItem="True" 
     ItemsSource="{Binding ComboUserData,Mode=TwoWay}" 
     SelectedItem="{Binding SelectedUserID}">
</ComboBox>

AnswerRe: Combobox data wont update WPF MVVM Pin
karthikeyal8712-Nov-13 22:58
karthikeyal8712-Nov-13 22:58 
GeneralRe: Combobox data wont update WPF MVVM Pin
LiquidHolic13-Nov-13 2:09
LiquidHolic13-Nov-13 2:09 
GeneralRe: Combobox data wont update WPF MVVM Pin
SledgeHammer0113-Nov-13 4:53
SledgeHammer0113-Nov-13 4:53 
GeneralRe: Combobox data wont update WPF MVVM Pin
LiquidHolic13-Nov-13 13:42
LiquidHolic13-Nov-13 13:42 
GeneralRe: Combobox data wont update WPF MVVM Pin
SledgeHammer0113-Nov-13 15:32
SledgeHammer0113-Nov-13 15:32 
GeneralRe: Combobox data wont update WPF MVVM Pin
LiquidHolic13-Nov-13 18:47
LiquidHolic13-Nov-13 18:47 
GeneralRe: Combobox data wont update WPF MVVM Pin
SledgeHammer0114-Nov-13 10:16
SledgeHammer0114-Nov-13 10:16 
GeneralRe: Combobox data wont update WPF MVVM Pin
LiquidHolic14-Nov-13 14:25
LiquidHolic14-Nov-13 14:25 
GeneralRe: Combobox data wont update WPF MVVM Pin
Pete O'Hanlon14-Nov-13 19:38
mvePete O'Hanlon14-Nov-13 19:38 
GeneralRe: Combobox data wont update WPF MVVM Pin
LiquidHolic14-Nov-13 19:54
LiquidHolic14-Nov-13 19:54 
AnswerRe: Combobox data wont update WPF MVVM Pin
w1sph1-Dec-13 22:45
w1sph1-Dec-13 22:45 
QuestionWPF ClickOnce eploy Question Pin
Kevin Marois7-Nov-13 4:57
professionalKevin Marois7-Nov-13 4:57 
AnswerRe: WPF ClickOnce eploy Question Pin
Abhinav S7-Nov-13 5:05
Abhinav S7-Nov-13 5:05 
GeneralRe: WPF ClickOnce eploy Question Pin
Kevin Marois7-Nov-13 5:07
professionalKevin Marois7-Nov-13 5:07 
AnswerRe: WPF ClickOnce eploy Question Pin
Abhinav S7-Nov-13 5:55
Abhinav S7-Nov-13 5:55 
AnswerRe: WPF ClickOnce eploy Question Pin
Wayne Gaylard7-Nov-13 20:05
professionalWayne Gaylard7-Nov-13 20:05 
QuestionHyperlink As TreeView Node Binding Problem Pin
Kevin Marois6-Nov-13 9:51
professionalKevin Marois6-Nov-13 9:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.