0

I'm new to WPF, so maybe i don't understand MVVM correctly. I use Microsoft Ribbon and I need to make a ribbon with dynamic tabs, whick are bind to my viewModel. I do this in such a way:

<Ribbon Grid.Row="1" ItemsSource="{Binding AvaliablePlugins}">
        <Ribbon.ApplicationMenu>
            <RibbonApplicationMenu SmallImageSource="Images\gear_32.png" KeyTip="F">
                <RibbonApplicationMenuItem Header="Exit" ImageSource="Images\stop_32.png" Command="{Binding CloseCommand}" />
                <RibbonApplicationMenuItem Header ="About" ImageSource="Images\bookmark.png" Click="ShowAbout"></RibbonApplicationMenuItem>
            </RibbonApplicationMenu>
        </Ribbon.ApplicationMenu>
        <Ribbon.ItemTemplate>
            <DataTemplate>
                <RibbonTab >
                    <RibbonTabHeader>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="24" />
                                <ColumnDefinition Width="24" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button Content="X" Click="ClosePlagin"></Button>
                            <Image Source="{Binding SmallImageSource}" Stretch="UniformToFill" Grid.Column="1" ></Image>
                            <TextBlock Text="{Binding Name}" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </RibbonTabHeader>
                </RibbonTab>
            </DataTemplate>
        </Ribbon.ItemTemplate>

Such binding worked correctly for tabControl and i can't get it working for wpf ribbon. Also, i'll then need to bind dynamic ribbonButtons to tabs and i don't how can i approach this. Myabe i have to store all ribbon parts (tab, group, button) in VM somehow? I also can't find good samples about WPF 4.5 Ribbon. And also, maybe it'll be better to choose third-party ribbon control, like telerik or syncfusion? By now microsoft solution doesn't make me feel happy.

I'll be gratefull for any help!

Alex Voskresenskiy
  • 2,143
  • 2
  • 20
  • 29

0 Answers0