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
--- Solution from Laurent ---
Yes, that's what i want,unfortunately VS.NET 2010 / Blend 4RC crashes after implementing it like this:
<Views:ViewDocumentSearchControl Visibility="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource BoolViz}}"/> <Views:ViewStartControl Visibility="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource BoolViz}}"/>
whenever i open the XAML in Blend / VS.NET i get a XYZ has stopped working. Changed the ValueConverter's return to Visibility.Visible, still the same. No idea. Thanks anyway! Christian
--- my (temporary) solution/workaround---
Okay, i ended up with this solution:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && parameter != null)
{
var val = (string) value;
var ctrl = (string) parameter;
if (val.Equals(ctrl))
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
return Visibility.Collapsed;
}
and set the .Tag of the RadOutlookBarItem in the Codebehind...