Solved

XAMLQuery to show and hide the controls in Silverlight 4.0 xaml

Posted on 2011-02-23
4
753 Views
Last Modified: 2013-11-12
Hi Experts,
I am using accordion control in silverlight 4.0 xaml. I need to hide the certain  labels , dropdowns, checkboxes, text boxes, radio buttons based on input passed into xaml page.Advance thanks.

Kind regards,
Pooja
0
Comment
Question by:poojasureshkumar
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
Comment Utility
can u give some more details please... where will these items be ? in accordion item ? are u using tool kit accordion or any other third party controls ?
0
 

Author Comment

by:poojasureshkumar
Comment Utility
Hi Qauthampi,
Items are in Accordion items. I am using accodrion took kit. Is there any way to use ajaxtool kit here. Because i am using so much accordion items and i could find difficulty in displaying controls for each accordion item.
Is there any way to show popup (with list of controls which was there for accordion item)  when i hit the accordion header.

Kind regards,
Pooja
0
 
LVL 3

Accepted Solution

by:
politex earned 500 total points
Comment Utility
Hi, it can be implemented like this


<UserControl.Resources>
        <my:Bool2Visibility x:Key="Bool2Visibility1" />
    </UserControl.Resources>
    <StackPanel>
    <toolkit:Accordion Height="150" x:Name="accordion1" Width="392" >
        <toolkit:Accordion.Items>
                <toolkit:AccordionItem Header="1" Visibility="{Binding ElementName=a1, Path=IsChecked, Mode=TwoWay, Converter={StaticResource Bool2Visibility1}}" />
                <toolkit:AccordionItem Header="2" Visibility="{Binding ElementName=a2, Path=IsChecked, Mode=TwoWay, Converter={StaticResource Bool2Visibility1}}"/>
                <toolkit:AccordionItem Header="3" Visibility="{Binding ElementName=a3, Path=IsChecked, Mode=TwoWay, Converter={StaticResource Bool2Visibility1}}"/>
                <toolkit:AccordionItem Header="4" Visibility="{Binding ElementName=a4, Path=IsChecked, Mode=TwoWay, Converter={StaticResource Bool2Visibility1}}"/>
        </toolkit:Accordion.Items>
    </toolkit:Accordion>
    <Popup IsOpen="True">
            <ListBox>
                <CheckBox x:Name="a1">1</CheckBox>
                <CheckBox x:Name="a2">2</CheckBox>
                <CheckBox x:Name="a3">3</CheckBox>
                <CheckBox x:Name="a4">4</CheckBox>
            </ListBox>
    </Popup>
    </StackPanel>

Open in new window

public class Bool2Visibility : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is bool)) return Visibility.Collapsed;
            return ((bool)value) ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Open in new window

0
 

Author Comment

by:poojasureshkumar
Comment Utility
Hi politex,
Thanks for a advice. I need to buy some additional time to test it since i am working on something else. Thanks for the patience.

Kind regards,
Pooja
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now