Note that there are some explanatory texts on larger screens.

plurals
  1. PORibbonTab IsSelected not working
    primarykey
    data
    text
    <p>I got a couple of <code>RibbonTab</code> who should be selected based on the type of <code>Content</code> in a <code>TabControl</code>.</p> <p>The problem is that sometimes it does not work, the error seems to occur more often on my remote Windows XP than my main computer with Windows 7 (maybe because it is slower). When the error occurs it does not help to switch tabs again and it does not work for any of the views who share the same <code>IValueConverter</code>.</p> <pre><code>&lt;ribbon:RibbonWindow Title="{Binding DisplayName}" x:Name="RibbonWindow" x:Class="Abc.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" xmlns:c="clr-namespace:Abc.Converters"&gt; &lt;ribbon:RibbonWindow.Resources&gt; &lt;c:FoobarConverter x:Key="Foobar" /&gt; &lt;c:FooConverter x:Key="Foo" /&gt; &lt;c:BarConverter x:Key="Bar" /&gt; &lt;/ribbon:RibbonWindow.Resources&gt; &lt;DockPanel&gt; &lt;ribbon:Ribbon DockPanel.Dock="Top"&gt; &lt;a:FoobarRibbonTab IsSelected="{Binding SelectedTab, Mode=OneWay, Converter={StaticResource Foobar}}" /&gt; &lt;a:FooRibbonTab IsSelected="{Binding SelectedTab, Mode=OneWay, Converter={StaticResource Foo}}" /&gt; &lt;a:BarRibbonTab IsSelected="{Binding SelectedTab, Mode=OneWay, Converter={StaticResource Bar}}" /&gt; &lt;/ribbon:Ribbon&gt; &lt;TabControl ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}"/&gt; &lt;/DockPanel&gt; </code></pre> <p></p> <pre><code>public class FooConverter : IValueConverter { public List&lt;Type&gt; ValidTypes = new List&lt;Type&gt;(); public FooConverter() { ValidTypes = new List&lt;Type&gt; { typeof(FooView), // etc... }; } public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var tabItemBase = value as TabItemBase; return tabItemBase != null &amp;&amp; tabItemBase.Content != null &amp;&amp; ValidTypes.Contains(tabItemBase.Content.GetType()); } public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p><strong>Update</strong></p> <p>Each <code>RibbonTab</code> has their own <code>Converter</code> and each <code>View</code> only exists in one <code>Converter</code>. When I use <code>Ctrl + Tab</code> the error occurs earlier.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload