You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've x:Bind with a custom control. Whenever I display the page (with the control), it crashes with the exception - System.Runtime.InteropServices.COMException: 'Unspecified error Cannot find a resource with the given key: BoolToVisibilityConverter.'
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace VulcanForWindows.UserControls
{
public sealed partial class SingleMessageBig : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); //error there
}
public static readonly DependencyProperty MessageProperty =
DependencyProperty.Register("Message", typeof(MessageViewModel), typeof(SingleMessageBig), new PropertyMetadata(null, Message_Changed));
public MessageViewModel Message
{
get => (MessageViewModel)GetValue(MessageProperty);
set => SetValue(MessageProperty, value); //error there
}
private static void Message_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is SingleMessageBig control && e.NewValue is MessageViewModel newValue)
{
control.OnPropertyChanged(nameof(Message)); //error there
}
}
void HoverOn(object sender, PointerRoutedEventArgs e)
{
if (e.OriginalSource is FrameworkElement element)
{
// Access the data of the item being hovered
MessageViewModel itemData = element.DataContext as MessageViewModel;
// Now, you can use itemData to access properties or perform actions
// For example, show additional information based on the data
if (itemData != null)
{
itemData.Hover = true;
}
}
}
void HoverOff(object sender, PointerRoutedEventArgs e)
{
if (e.OriginalSource is FrameworkElement element)
{
// Access the data of the item being hovered
MessageViewModel itemData = element.DataContext as MessageViewModel;
// Now, you can use itemData to access properties or perform actions
// For example, show additional information based on the data
if (itemData != null)
{
itemData.Hover = true;
}
}
}
public SingleMessageBig()
{
OnPropertyChanged(nameof(Message));
this.InitializeComponent();
AddHandler(PointerEnteredEvent, new PointerEventHandler(HoverOn), true);
AddHandler(PointerExitedEvent, new PointerEventHandler(HoverOff), true);
}
}
}
Couldn't find any way to fix it. Changing to Binding doesn't work. What's the issue?
The text was updated successfully, but these errors were encountered:
Hi, I've x:Bind with a custom control. Whenever I display the page (with the control), it crashes with the exception - System.Runtime.InteropServices.COMException: 'Unspecified error Cannot find a resource with the given key: BoolToVisibilityConverter.'
MessagesPage.xaml
SingleMessageBig.xaml
SingleMessageBig.xaml.cs
Couldn't find any way to fix it. Changing to Binding doesn't work. What's the issue?
The text was updated successfully, but these errors were encountered: