Click here to Skip to main content
15,867,330 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Problem in VisualTreeHelper.GetParent. Please guide me [modified] Pin
Mark Salsbery10-May-11 8:46
Mark Salsbery10-May-11 8:46 
GeneralRe: Problem in VisualTreeHelper.GetParent. Please guide me Pin
Hema Bairavan10-May-11 22:57
Hema Bairavan10-May-11 22:57 
QuestionRe: Problem in VisualTreeHelper.GetParent. Please guide me Pin
Mark Salsbery11-May-11 4:49
Mark Salsbery11-May-11 4:49 
QuestionWPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 5:01
Nicolai Schrade10-May-11 5:01 
AnswerRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Ian Shlasko10-May-11 5:38
Ian Shlasko10-May-11 5:38 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 6:00
Nicolai Schrade10-May-11 6:00 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Ian Shlasko10-May-11 6:09
Ian Shlasko10-May-11 6:09 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 6:35
Nicolai Schrade10-May-11 6:35 
I'm not sure I understand your answer, sorry.
The datagrid's ItemsSource is bound to the ViewModel (it is bound to a ViewModel's property of type ObservableCollection).

What I did now is:
<DataGrid.CellStyle>
    <Style TargetType="{x:Type DataGridCell}">
        <Setter Property="Foreground" Value="Black"/>

        <Setter Property="Background"
       Value="{Binding Path=DataContext.CellBackground, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl, AncestorLevel=1}}"/>
    </Style>
</DataGrid.CellStyle>


This works, but I'm sure that's not the most elegant solution...
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Ian Shlasko10-May-11 6:52
Ian Shlasko10-May-11 6:52 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 22:57
Nicolai Schrade10-May-11 22:57 
AnswerRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Pete O'Hanlon10-May-11 6:35
subeditorPete O'Hanlon10-May-11 6:35 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Nicolai Schrade10-May-11 22:58
Nicolai Schrade10-May-11 22:58 
GeneralRe: WPF Datagrid and MVVM - Binding CellStyle to a ViewModel Property Pin
Pete O'Hanlon10-May-11 23:46
subeditorPete O'Hanlon10-May-11 23:46 
QuestionStretch StatusBarItem Pin
Jean-Louis Leroy10-May-11 4:06
Jean-Louis Leroy10-May-11 4:06 
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 
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 

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.