Esempio n. 1
0
        private StackPanel CreateRightStackPanelForInput(Language lang)
        {
            // Checks if the category already contains a localized category for said language.
            LocalizedCategory locCat = CategoryModel.LocalizedCategories.FirstOrDefault(x => x.LanguageID == lang.ID);

            // If the category does not contain one yet,
            if (locCat == null)
            {
                // Create a new one and add it to the model
                locCat = new LocalizedCategory
                {
                    LanguageID = lang.ID
                };
                CategoryModel.LocalizedCategories.Add(locCat);
            }

            // Creates a stackpanel
            StackPanel stackRight = new StackPanel();

            // Creates a new textbox for the Name property
            ClickSelectTextBox txtName = new ClickSelectTextBox
            {
                Height = _defaultHeight,
                Width  = _defaultWidth,
                Margin = _defaultMargin,
                VerticalContentAlignment = VerticalAlignment.Center
            };
            // Creates a binding with source the localized category and binds it to the Name property
            Binding nameBinding = new Binding("Name")
            {
                Source = locCat
            };

            // Adds the binding to the textbox
            txtName.SetBinding(TextBox.TextProperty, nameBinding);

            // Idem for the plural name textbox
            ClickSelectTextBox txtPluralName = new ClickSelectTextBox
            {
                Height = _defaultHeight,
                Width  = _defaultWidth,
                Margin = _defaultMargin,
                VerticalContentAlignment = VerticalAlignment.Center
            };
            Binding pluralNameBinding = new Binding("PluralName")
            {
                Source = locCat
            };

            txtPluralName.SetBinding(TextBox.TextProperty, pluralNameBinding);

            // Adds both textboxes to the stackpanels
            stackRight.Children.Add(txtName);
            stackRight.Children.Add(txtPluralName);

            return(stackRight);
        }
Esempio n. 2
0
 public LocalizedCategoryOutput(LocalizedCategory localizedCategory)
 {
     this.LanguageCode = localizedCategory.LanguageCode;
     this.Name         = localizedCategory.Name;
     this.Description  = localizedCategory.Description;
 }