Skip to content

How do I create a Gtk.PropertyExpression? #1099

Closed Answered by Daniel15
Daniel15 asked this question in Q&A
Discussion options

You must be logged in to vote

This is what I ended up with for ComboRow as a workaround to PropertyExpression not being usable. I'm using a StringList model rather than a ListStore, and keeping a mapping from the label to the original item. Works fine as long as all labels are unique.

using Adw;
using Gtk;

namespace WebCamControl.Gtk;

/// <summary>
/// Wrapper around <see cref="ComboRow"/> that allows C# types to be used as items.
/// </summary>
/// <typeparam name="T">Type of item</typeparam>
public class CustomComboRow<T> : ComboRow
{
	private Dictionary<string, T> _labelToItem = new();

	public CustomComboRow(IntPtr ptr, bool ownedRef) : base(ptr, ownedRef) { }

	/// <summary>
	/// Gets or sets a callback to get …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Daniel15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant