Replies: 1 comment
-
|
I have exactly the same issue. I used the selection guide as base it works completely fine when I use a A code snippet of what I'm doing: [ImplicitKeys(IsEnabled = false)]
public partial record OneDriveItem(string Id, string Name, ICollection<OneDriveItem> Children);
public partial record MainModel
{
private readonly IOneDriveService _oneDriveService;
public IListFeed<OneDriveItem> CameraRollFolderItems => ListFeed.Async(_oneDriveService.GetCameraRollFolderAsync).Selection(SelectedCameraRollItem);
public IState<OneDriveItem> SelectedCameraRollItem => State<OneDriveItem>.Value(this, () => new OneDriveItem("", "", []));
public MainModel(IOneDriveService oneDriveService)
{
_oneDriveService = oneDriveService;
SelectedCameraRollItem.ForEach(action: SelectionChanged);
}
public async ValueTask SelectionChanged(OneDriveItem? selectedCameraRollItem, CancellationToken ct)
{
if (selectedCameraRollItem == null)
return;
...
}
}public sealed partial class MainPage : Page
{
public MainPage()
{
this.DataContext<MainViewModel>((page, vm) => page
.Content(new Grid()
.Children(
new ElevatedView()
.Background(Theme.Brushes.Surface.Default)
.CornerRadius(new CornerRadius(5))
.Elevation(10)
.Margin(new Thickness(10, 10, 0, 10))
.ElevatedContent(new FeedView()
.Source(() => vm.CameraRollFolderItems)
.ValueTemplate<FeedViewState>(feedViewState => new TreeViewList()
.HorizontalAlignment(HorizontalAlignment.Stretch)
.VerticalAlignment(VerticalAlignment.Stretch)
.CanDrag(false)
.CanDragItems(false)
.CanReorderItems(false)
.ItemsSource(() => feedViewState.Data)
.ItemTemplate<OneDriveItem>((item) => new TreeViewItem()
.Content(() => item.Name)
.ItemsSource(() => item.Children))
.SelectionMode(ListViewSelectionMode.Single)))));
}
}Maybe you have to do some extra binding on the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to bind treeview.SelectedItem with model (mvux)
` <mvux:FeedView Grid.Row="1"
Source="{Binding Items}">
<muxc:TreeView ItemsSource="{Binding Data}"
SelectedItem="{utu:AncestorBinding AncestorType=Page, Path=DataContext.SelectedItem}"
CanDragItems="False"
AllowDrop="False"
SelectionMode="Single">
</mvux:FeedView>`
This option does not work, most likely because it's not enough Mode=TwoWay
Option
` public IState SelectedItemFeed => State.Empty(this)
.ForEach(action: SelectedItemFeedChanged);
public IListFeed Items =>
ListFeed.Async(GetItemsAsync)
.Selection(SelectedItemFeed);`
Does not work
how to solve this problem? Thank you.
Beta Was this translation helpful? Give feedback.
All reactions