Click here to Skip to main content
15,885,546 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Stretch StatusBarItem Pin
Ian Shlasko10-May-11 4:35
Ian Shlasko10-May-11 4:35 
GeneralRe: Stretch StatusBarItem Pin
Jean-Louis Leroy10-May-11 5:08
Jean-Louis Leroy10-May-11 5:08 
QuestionDatabinding CheckBox in a ListBox Pin
kurmanc9-May-11 6:30
kurmanc9-May-11 6:30 
AnswerRe: Databinding CheckBox in a ListBox Pin
Ian Shlasko9-May-11 6:36
Ian Shlasko9-May-11 6:36 
GeneralRe: Databinding CheckBox in a ListBox [modified] Pin
kurmanc9-May-11 8:38
kurmanc9-May-11 8:38 
GeneralRe: Databinding CheckBox in a ListBox Pin
Ian Shlasko9-May-11 8:46
Ian Shlasko9-May-11 8:46 
GeneralRe: Databinding CheckBox in a ListBox Pin
kurmanc9-May-11 21:23
kurmanc9-May-11 21:23 
GeneralRe: Databinding CheckBox in a ListBox Pin
kurmanc11-May-11 6:11
kurmanc11-May-11 6:11 
Hi Ian,

I have now been trying to figure out how to "Select/Deselect All" checkboxes. My approach is the following:

Model
I have a IsSelected property in my Product class (in that class I also have productName, etc).
...
public string ProductName { get; set; }
...
private bool _isSelected;
public bool IsSelected
{
get
{
    return _isSelected;
}
set
{
    _isSelected = value;
    OnPropertyChanged("IsSelected");
}
}


public event PropertyChangedEventHandler PropertyChanged;

protected void OnPropertyChanged(string name)
{
    PropertyChangedEventHandler handler = PropertyChanged;

    if (handler != null)
    {
        handler(this, new PropertyChangedEventArgs(name));
    }
}


ViewModel
...
void CheckAllCommandExecute()
{
    foreach (Model.Product product in AllProducts)
    {
        if (product.IsSelected == false)
        {
            product.IsSelected = true;
        }
        else
            product.IsSelected = false;
    }
}
...


View
<ItemsControl ItemsSource="{Binding AllProducts}">
...
<CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
...
<TextBlock VerticalAlignment="Center" Grid.Column="1" Text="{Binding Path=ProductName}" />

...
<ButtonContent="Select/Deselect All" Command="{Binding Path=CheckAllCommand}" />


I thought OnPropertyChanged method would update the checkboxes either checked or unchecked. What do I do wrong?

Thanks in advance.
GeneralRe: Databinding CheckBox in a ListBox Pin
Ian Shlasko11-May-11 11:47
Ian Shlasko11-May-11 11:47 
GeneralRe: Databinding CheckBox in a ListBox Pin
kurmanc11-May-11 21:17
kurmanc11-May-11 21:17 
QuestionCan you make a treeview behave like a tabcontrol? Pin
bfis1081379-May-11 6:16
bfis1081379-May-11 6:16 
AnswerRe: Can you make a treeview behave like a tabcontrol? Pin
Ian Shlasko9-May-11 6:31
Ian Shlasko9-May-11 6:31 
QuestionBool To Visibility Converter Problem Pin
Kevin Marois9-May-11 5:57
professionalKevin Marois9-May-11 5:57 
AnswerRe: Bool To Visibility Converter Problem Pin
Ian Shlasko9-May-11 6:09
Ian Shlasko9-May-11 6:09 
GeneralRe: Bool To Visibility Converter Problem Pin
Kevin Marois9-May-11 6:11
professionalKevin Marois9-May-11 6:11 
GeneralRe: Bool To Visibility Converter Problem Pin
Ian Shlasko9-May-11 6:19
Ian Shlasko9-May-11 6:19 
AnswerRe: Bool To Visibility Converter Problem Pin
SledgeHammer019-May-11 10:20
SledgeHammer019-May-11 10:20 
GeneralRe: Bool To Visibility Converter Problem Pin
AspDotNetDev9-May-11 11:09
protectorAspDotNetDev9-May-11 11:09 
Questionhow to get selected datagrid row items ? Pin
SRKSHOME8-May-11 21:28
SRKSHOME8-May-11 21:28 
AnswerRe: how to get selected datagrid row items ? Pin
Pete O'Hanlon8-May-11 21:44
mvePete O'Hanlon8-May-11 21:44 
GeneralRe: how to get selected datagrid row items ? Pin
SRKSHOME8-May-11 22:36
SRKSHOME8-May-11 22:36 
GeneralRe: how to get selected datagrid row items ? Pin
Pete O'Hanlon9-May-11 0:19
mvePete O'Hanlon9-May-11 0:19 
Questioncustom query Pin
picasso27-May-11 7:52
picasso27-May-11 7:52 
AnswerRe: custom query Pin
Pete O'Hanlon7-May-11 8:29
mvePete O'Hanlon7-May-11 8:29 
QuestionHow to set default location for google map on WP7 Pin
Nguyen Thanh Duc6-May-11 23:30
Nguyen Thanh Duc6-May-11 23:30 

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.