Problems with RibbonComboBox

1

Good afternoon, we are developing a text editing tool. In it we are using the menus with the "RibbonControlsLibrary", and so far everything is right. When I decided to use RibbonComboBox it started the problem, based on an example I tried to reach a solution, but I can not pass the information created to the UI.

XAML:

<r:RibbonComboBox x:Name="rcbFontFamily" DataContext="{x:Static data:EditorTexto_ViewModel.FontFace}">
    <r:RibbonGallery MaxColumnCount="1">
        <r:RibbonGallery.GalleryItemTemplate>
            <DataTemplate>
                <Grid>
                    <TextBlock Text="{Binding}" FontFamily="{Binding}"/>
                </Grid>
            </DataTemplate>
        </r:RibbonGallery.GalleryItemTemplate>
    </r:RibbonGallery>

FontFace:

public static ControlData FontFace
    {
        get
        {
            lock (_lockObject)
            {
                string Str = "Font Face";

                if (!_dataCollection.ContainsKey(Str))
                {
                    GalleryData<FontFamily> galleryData = new GalleryData<FontFamily>()
                    {
                        SelectedItem = SystemFonts.MessageFontFamily,
                    };

                    GalleryCategoryData<FontFamily> allFontsCategoryData = new GalleryCategoryData<FontFamily>()
                    {
                        Text = "Todas as fontes"
                    };

                    foreach (FontFamily fontFamily in System.Windows.Media.Fonts.SystemFontFamilies)
                    {
                        allFontsCategoryData.GalleryItemDataCollection.Add(fontFamily);

                    }

                    galleryData.CategoryDataCollection.Add(allFontsCategoryData);

                    Action<FontFamily> ChangeFontFace = delegate(FontFamily parameter)
                    {
                        if (AppWindow != null)
                        {
                            AppWindow.ChangeFontFace(parameter);
                        }
                    };

                    Func<FontFamily, bool> CanChangeFontFace = delegate(FontFamily parameter)
                    {
                        if (AppWindow != null)
                        {
                            return AppWindow.CanChangeFontFace(parameter);
                        }

                        return false;
                    };

                    Action<FontFamily> PreviewFontFace = delegate(FontFamily parameter)
                    {
                        if (AppWindow != null)
                        {
                            AppWindow.PreviewFontFace(parameter);
                        }
                    };

                    Action CancelPreviewFontFace = delegate()
                    {
                        if (AppWindow != null)
                        {
                            AppWindow.CancelPreviewFontFace();
                        }
                    };

                    galleryData.Command = new officersoft.editor.MainWindow.PreviewDelegateCommand<FontFamily>(ChangeFontFace, CanChangeFontFace, PreviewFontFace, CancelPreviewFontFace);

                    _dataCollection[Str] = galleryData;
                }

                return _dataCollection[Str];
            }
        }
    }

If you need more information just ask and apologize for any error, I'm new to C # / wpf.

Solution : To set the information it was necessary only to create the following XAML code:

<r:RibbonComboBox 
    x:Name="rcbFontFamily" 
    SelectionBoxWidth="160"
    IsEditable="True">
    <r:RibbonGallery
        Name="_rgFontFamily"
        ScrollViewer.VerticalScrollBarVisibility="Visible"
        Command="{StaticResource FontFamilyHandler}">
        <r:RibbonGalleryCategory
            Name="_rgcFontFamily"
            ItemsSource="{Binding Source={x:Static Fonts.SystemFontFamilies}}"/>
    </r:RibbonGallery>
</r:RibbonComboBox>

If there is any question, just ask.

    
asked by anonymous 23.12.2015 / 19:33

1 answer

0

Solution: In order to set the information, it was only necessary to create the following XAML code:

<r:RibbonComboBox 
    x:Name="rcbFontFamily" 
    SelectionBoxWidth="160"
    IsEditable="True">
    <r:RibbonGallery
        Name="_rgFontFamily"
        ScrollViewer.VerticalScrollBarVisibility="Visible"
        Command="{StaticResource FontFamilyHandler}">
        <r:RibbonGalleryCategory
            Name="_rgcFontFamily"
            ItemsSource="{Binding Source={x:Static Fonts.SystemFontFamilies}}"/>
    </r:RibbonGallery>
</r:RibbonComboBox>

If there is any question, just ask.

    
12.01.2016 / 17:30