This is a migrated thread and some comments may be shown as answers.

MVVM Binding Selected OutlookBarItem

1 Answer 157 Views
OutlookBar
This is a migrated thread and some comments may be shown as answers.
Christian Casutt
Top achievements
Rank 1
Christian Casutt asked on 20 Apr 2010, 08:10 AM
Imagine: 

[RadOutlookBarItem1]
[RadOutlookBarItem2]
[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; } 
            set 
            { 
                _showControl = value; 
                OnNotifyPropertyChanged("ShowControl"); 
            } 
        } 


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

    <UserControl.Resources> 
        <Converters:BoolVisibilityConverter x:Key="BoolViz"/> 
    </UserControl.Resources> 
    <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'}"/> 
    </Grid> 

Converter: 

        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 
             
            System.Diagnostics.Debugger.Break(); 
            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

Christian

1 Answer, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 22 Apr 2010, 03:01 PM
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 :
<UserControl.Resources>
    <Converters:BoolVisibilityConverter x:Key="BoolViz"/>
</UserControl.Resources>
   <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'}"/>
   </Grid>

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.
Tags
OutlookBar
Asked by
Christian Casutt
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Share this question
or