Click here to Skip to main content
15,897,273 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: The Property 'Content' is set more than once - I cant see were I am doing this Pin
Abhinav S26-Mar-11 6:20
Abhinav S26-Mar-11 6:20 
QuestionWCF: Message Security with a User Name Client - how to retrieve username+pwd from server side on a per request basis? [modified] Pin
devvvy24-Mar-11 22:16
devvvy24-Mar-11 22:16 
AnswerRe: WCF: Message Security with a User Name Client - how to retrieve username+pwd from server side on a per request basis? Pin
SledgeHammer0125-Mar-11 11:02
SledgeHammer0125-Mar-11 11:02 
GeneralRe: WCF: Message Security with a User Name Client - how to retrieve username+pwd from server side on a per request basis? Pin
devvvy27-Mar-11 21:57
devvvy27-Mar-11 21:57 
QuestionWrapPanel Bound To Collection Pin
Kevin Marois24-Mar-11 12:09
professionalKevin Marois24-Mar-11 12:09 
AnswerRe: WrapPanel Bound To Collection Pin
Mycroft Holmes24-Mar-11 12:46
professionalMycroft Holmes24-Mar-11 12:46 
GeneralRe: WrapPanel Bound To Collection Pin
Kevin Marois24-Mar-11 12:57
professionalKevin Marois24-Mar-11 12:57 
GeneralRe: WrapPanel Bound To Collection Pin
Kevin Marois24-Mar-11 13:29
professionalKevin Marois24-Mar-11 13:29 
Ok, this works great. The buttons all appear in the WrapPanel with text & images as they should, except for 2 issues:

1) I'm using telerik:RadRadioButtons. They're not acting like radio buttons now. ie - I can select one, all, or some.
2) The Command binding isn't working. Clicking the button does not get a response:

I think these problems are the result of the fact the list is dynamic and populatd at runtime. Any thoghts?

Here's the XAML:
<ItemsControl Grid.Row="1" 
                Grid.Column="0"
                Margin="10"
                ItemsSource="{Binding TemplateTypes}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <telerik:RadRadioButton Command="{Binding SelectedTemplate}" 
                                    HorizontalContentAlignment="Center" 
                                    Height="175"
                                    Width="120">
                <Grid >
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Image Grid.Row="0" 
                            Stretch="Fill"
                            Height="64"
                            Width="64"
                            Source="{Binding Path=ImageFile}" />
                    <TextBlock Grid.Row="1" 
                                Text="{Binding Path=Caption}" 
                                HorizontalAlignment="Center" 
                                TextWrapping="Wrap"/>
                </Grid>
            </telerik:RadRadioButton>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>


And the code behind:
public class mv_FileNewViewModel : _ViewModelBase
{
    #region Properties
    private ObservableCollection<MenuButtonData> _TemplateTypes = new ObservableCollection<MenuButtonData>();
    public ObservableCollection<MenuButtonData> TemplateTypes
    {
        get { return _TemplateTypes; }
        set
        {
            if (_TemplateTypes != value)
            {
                _TemplateTypes = value;
                RaisePropertyChanged("TemplateTypes");
            }
        }
    }
    #endregion

    #region Command Properties
    private ICommand _SelectedTemplate;
    public ICommand SelectedTemplate
    {
        get
        {
            if (_SelectedTemplate == null)
                _SelectedTemplate = new RelayCommand(SelectedTemplateExecuted, SelectedTemplateCanExecute);

            return _SelectedTemplate;
        }
    }
    #endregion

    #region Command Handlers
    public bool SelectedTemplateCanExecute()
    {
        return true;
    }
    public void SelectedTemplateExecuted()
    {
        // THIS SHOULD FIRE WHEN A BUTTON IS CLICKED 
    }
    #endregion

    #region Private Methods
    private void loadTemplateTypes()
    {
        TemplateTypes.Add(new MenuButtonData { Caption = "Presentations", ImageFile = @"C:\Users\kmarois\Documents\My Dropbox\Raptor\Raptor\Media\Graphics\presentation_64x64.png" });
        TemplateTypes.Add(new MenuButtonData { Caption = "Slides", ImageFile = @"C:\Users\kmarois\Documents\My Dropbox\Raptor\Raptor\Media\Graphics\slide_48x52.png" });
        TemplateTypes.Add(new MenuButtonData { Caption = "Controls", ImageFile = @"C:\Users\kmarois\Documents\My Dropbox\Raptor\Raptor\Media\Graphics\control_72x72.png" });
        TemplateTypes.Add(new MenuButtonData { Caption = "Templates", ImageFile = @"C:\Users\kmarois\Documents\My Dropbox\Raptor\Raptor\Media\Graphics\template_32x32.png" });
        TemplateTypes.Add(new MenuButtonData { Caption = "Themes", ImageFile = @"C:\Users\kmarois\Documents\My Dropbox\Raptor\Raptor\Media\Graphics\theme_64x64.png" });
    }
    #endregion
}

Everything makes sense in someone's mind

GeneralRe: WrapPanel Bound To Collection Pin
SledgeHammer0124-Mar-11 14:06
SledgeHammer0124-Mar-11 14:06 
GeneralRe: WrapPanel Bound To Collection Pin
Kevin Marois24-Mar-11 14:25
professionalKevin Marois24-Mar-11 14:25 
GeneralRe: WrapPanel Bound To Collection Pin
SledgeHammer0124-Mar-11 15:10
SledgeHammer0124-Mar-11 15:10 
GeneralRe: WrapPanel Bound To Collection Pin
SledgeHammer0124-Mar-11 15:13
SledgeHammer0124-Mar-11 15:13 
GeneralRe: WrapPanel Bound To Collection Pin
Mycroft Holmes24-Mar-11 15:50
professionalMycroft Holmes24-Mar-11 15:50 
GeneralRe: WrapPanel Bound To Collection [modified] Pin
Kim Breugelmans24-Mar-11 20:19
Kim Breugelmans24-Mar-11 20:19 
GeneralRe: WrapPanel Bound To Collection Pin
Kevin Marois25-Mar-11 5:43
professionalKevin Marois25-Mar-11 5:43 
GeneralRe: WrapPanel Bound To Collection Pin
SledgeHammer0125-Mar-11 6:32
SledgeHammer0125-Mar-11 6:32 
GeneralRe: WrapPanel Bound To Collection Pin
Kevin Marois25-Mar-11 7:07
professionalKevin Marois25-Mar-11 7:07 
GeneralOk Everyone, Here It Is Pin
Kevin Marois25-Mar-11 7:31
professionalKevin Marois25-Mar-11 7:31 
GeneralRe: WrapPanel Bound To Collection Pin
Kim Breugelmans25-Mar-11 7:04
Kim Breugelmans25-Mar-11 7:04 
GeneralRe: WrapPanel Bound To Collection Pin
SledgeHammer0125-Mar-11 9:30
SledgeHammer0125-Mar-11 9:30 
QuestionWPF binding to a simple CLR Property? (Visibility=Collapsed) Pin
devvvy23-Mar-11 16:23
devvvy23-Mar-11 16:23 
AnswerRe: WPF binding to a simple CLR Property? (Visibility=Collapsed) Pin
devvvy23-Mar-11 19:42
devvvy23-Mar-11 19:42 
AnswerRe: WPF binding to a simple CLR Property? (Visibility=Collapsed) Pin
Pete O'Hanlon23-Mar-11 23:03
mvePete O'Hanlon23-Mar-11 23:03 
QuestionBook - Silverlight 4 - Problem Design Solution Pin
arkiboys23-Mar-11 2:41
arkiboys23-Mar-11 2:41 
AnswerRe: Book - Silverlight 4 - Problem Design Solution Pin
Mycroft Holmes23-Mar-11 12:20
professionalMycroft Holmes23-Mar-11 12:20 

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.