Click here to Skip to main content
15,908,274 members
Home / Discussions / WPF
   

WPF

 
Questionvisualstudio/experssion blend Pin
arkiboys13-Jul-11 10:31
arkiboys13-Jul-11 10:31 
AnswerRe: visualstudio/experssion blend Pin
Mark Salsbery13-Jul-11 11:24
Mark Salsbery13-Jul-11 11:24 
AnswerRe: visualstudio/experssion blend Pin
Abhinav S13-Jul-11 20:37
Abhinav S13-Jul-11 20:37 
AnswerRe: visualstudio/experssion blend Pin
Kunal Chowdhury «IN»20-Jul-11 0:19
professionalKunal Chowdhury «IN»20-Jul-11 0:19 
AnswerRe: visualstudio/experssion blend Pin
Oludayo Alli20-Aug-11 7:15
Oludayo Alli20-Aug-11 7:15 
GeneralRe: visualstudio/experssion blend Pin
arkiboys20-Aug-11 7:20
arkiboys20-Aug-11 7:20 
GeneralRe: visualstudio/experssion blend Pin
Oludayo Alli20-Aug-11 8:39
Oludayo Alli20-Aug-11 8:39 
QuestionBind to converter in XAML Pin
_Madmatt13-Jul-11 9:54
_Madmatt13-Jul-11 9:54 
Hey all,

I'm running into a problem when binding a property of a GroupItemTemplate (in the WP7 LongListSelector) to a converter I built. I want the converter to check if there are items to be displayed in the group, and according to if there are items, set a Brush to the background.

This is my code for the Converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is Group<TrackInfo>)
            {
                Group<TrackInfo> group = value as Group<TrackInfo>;
                if (group != null)
                {
                    if (group.Items.Count == 0)
                        return (SolidColorBrush)Application.Current.Resources["PhoneChromeBrush"];
                    else
                        return (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
                }
            }

            return new SolidColorBrush(Color.FromArgb(128, 255, 0, 0));
        }


And this is in my XAML:

<DataTemplate x:Key="groupItemTemplate">
            <Border Width="99" Height="99" Background="{Binding Converter={StaticResource groupItemBackgroundBrush}}" Margin="6" IsHitTestVisible="{Binding HasItems}">
                <TextBlock Text="{Binding GroupTitle}" 
                                       FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                       FontSize="36"
                                       Margin="{StaticResource PhoneTouchTargetOverhang}"
                                       Foreground="{StaticResource PhoneForegroundBrush}"                                        
                                       VerticalAlignment="Bottom"/>
            </Border>
        </DataTemplate>
        
        <valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />

...

<toolkit:LongListSelector x:Name="lstTracks"  Height="800" Width="480" DisplayAllGroups="True"
        ListHeaderTemplate="{StaticResource listHeader}"
        ListFooterTemplate="{StaticResource listFooter}"
        ItemTemplate="{StaticResource itemTemplate}"
        GroupHeaderTemplate="{StaticResource groupHeaderTemplate}"
        GroupItemTemplate="{StaticResource groupItemTemplate}">
        <toolkit:LongListSelector.GroupItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </toolkit:LongListSelector.GroupItemsPanel>
    </toolkit:LongListSelector>


I get an Unspecified Error, wich isn't exactly quite helpful... Is there a better way to find out if the group has items and accordingly set a Brush? Or is there an error in my code I don't see?

Thanks for helping,
MadMatt
AnswerRe: Bind to converter in XAML [modified] Pin
Mark Salsbery13-Jul-11 11:27
Mark Salsbery13-Jul-11 11:27 
GeneralRe: Bind to converter in XAML Pin
_Madmatt13-Jul-11 23:41
_Madmatt13-Jul-11 23:41 
GeneralRe: Bind to converter in XAML Pin
Pete O'Hanlon14-Jul-11 0:02
mvePete O'Hanlon14-Jul-11 0:02 
GeneralRe: Bind to converter in XAML Pin
_Madmatt14-Jul-11 0:29
_Madmatt14-Jul-11 0:29 
GeneralRe: Bind to converter in XAML Pin
Pete O'Hanlon14-Jul-11 0:53
mvePete O'Hanlon14-Jul-11 0:53 
GeneralRe: Bind to converter in XAML Pin
_Madmatt14-Jul-11 1:27
_Madmatt14-Jul-11 1:27 
GeneralRe: Bind to converter in XAML Pin
skv_lviv14-Jul-11 20:01
skv_lviv14-Jul-11 20:01 
GeneralRe: Bind to converter in XAML Pin
_Madmatt17-Jul-11 0:23
_Madmatt17-Jul-11 0:23 
AnswerRe: Bind to converter in XAML Pin
Abhinav S13-Jul-11 20:44
Abhinav S13-Jul-11 20:44 
GeneralRe: Bind to converter in XAML Pin
_Madmatt13-Jul-11 23:43
_Madmatt13-Jul-11 23:43 
QuestionMembership Role Pin
picasso212-Jul-11 17:24
picasso212-Jul-11 17:24 
AnswerRe: Membership Role Pin
Mark Salsbery13-Jul-11 11:56
Mark Salsbery13-Jul-11 11:56 
GeneralRe: Membership Role Pin
picasso213-Jul-11 20:22
picasso213-Jul-11 20:22 
GeneralRe: Membership Role Pin
Mark Salsbery14-Jul-11 10:50
Mark Salsbery14-Jul-11 10:50 
GeneralRe: Membership Role Pin
Mark Salsbery14-Jul-11 10:55
Mark Salsbery14-Jul-11 10:55 
QuestionWhy does Microsoft do this to me Pin
Tad McClellan12-Jul-11 12:58
professionalTad McClellan12-Jul-11 12:58 
AnswerRe: Why does Microsoft do this to me Pin
Mark Salsbery13-Jul-11 11:51
Mark Salsbery13-Jul-11 11: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.