Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
46
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

Chapter 6 Creating Our Own Layout

private void Widgets_ChildAdded(object sender, ElementEventArgs e)

{

if (e.Element is IWidgetView widgetView)

{

LayoutManager.SetPosition(e.Element, widgetView. Position);

}

}

This handler checks to see if the new child being added is of the IWidgetView type, and if it is, it delegates out to the LayoutManager implementation to set the widget’s position.

Adding Remaining Bits

You have a few extra methods and properties to add in that will be used by the FixedLayoutManager. Let’s add them and discuss their purpose as you go.

Add the using statement at the top of the file.

using WidgetBoard.Controls;

Then add the first new method.

public void AddPlaceholder(Placeholder placeholder) => PlaceholderGrid.Children.Add(placeholder);

This method allows the caller to pass a placeholder that will be added to PlaceholderGrid. This is useful when first loading a board or when dealing with a widget being removed from a specific position.

public void RemovePlaceholder(Placeholder placeholder) => PlaceholderGrid.Children.Remove(placeholder);

176