MVVM Binding Selected OutlookBarItem

2 posts, 1 answers
  1. Christian Muggli
    Christian Muggli avatar
    7 posts
    Member since:
    Jul 2009

    Posted 20 Apr 2010 Link to this post


    [RadOutlookBar] [CONTENCONTROL]

    What i want to achieve is:

    User selects one of the RadOutlookBarItem's. Item's tag is bound like:

    Tag="{Binding SelectedControl, Mode=TwoWay}" 

    MVVM Property

            public string SelectedControl 
                get { return _showControl; } 
                    _showControl = value; 

    ContentControl has multiple CustomControls and Visibility of those is bound like:

            <Converters:BoolVisibilityConverter x:Key="BoolViz"/> 
        <Grid x:Name="LayoutRoot" Background="White"
            <Views:ViewDocumentSearchControl Visibility="{Binding SelectedControl, Converter={StaticResource BoolViz}, ConverterParameter='viewDocumentSearchControl'}"/> 
            <Views:ViewStartControl Visibility="{Binding SelectedControl, Converter={StaticResource BoolViz}, ConverterParameter='viewStartControl'}"/> 


            public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
                // here comes the logic part... should return Visibility.Collapsed : Visibility.Visible based on 'object value' value 
                return Visibility.Collapsed;  

    now, logically the object value is always set to null. So here's it comes to my question: How can i put a value into the SelectedControl Variable for the RadOutlookBarItem's Tag. I mean something like 
    Tag="{Binding SelectedControl, Mode=TwoWay, VALUE='i.e.ControlName'"}

    So that i can decide, using the Convert Method, whether a specific Control's visibility is either set to collapsed or visible?

    help's appreciated

  2. Answer
    Miro Miroslavov
    Miro Miroslavov avatar
    588 posts

    Posted 22 Apr 2010 Link to this post

    Hello Christian Muggli,

    In that case you'd better not use this property from the ViewModel and do it like follows:

    1. Set each RadOutlookBarItem.Tag = "some id string"
    2. Bind the ContentControl :
        <Converters:BoolVisibilityConverter x:Key="BoolViz"/>
       <Grid x:Name="LayoutRoot" Background="White">
           <Views:ViewDocumentSearchControl Visibility="{Binding ElementName=radOutlookBar1, Path=SelectedItem.Tag, Converter={StaticResource BoolViz}, ConverterParameter='viewDocumentSearchControl'}"/>
           <Views:ViewStartControl Visibility="{Binding ElementName=radOutlookBar1, Path=SelectedItem.Tag, Converter={StaticResource BoolViz}, ConverterParameter='viewStartControl'}"/>

    where radOutlookBar1 is the name of the OutlookBarItem.
    And implement the converter as you said.
    If you have further questions regarding the implementation, please ask us.
    Kind regards,
    Miro Miroslavov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
Back to Top