xaml

WebView2 control not loading HTML string

痞子三分冷 提交于 2020-08-09 19:15:27
问题 WebView2 Control: As shown below, the HTML String successfully loads via NavigateToString(...) call inside Button_Click(...) event. But I need to have the HTML string loaded as soon as the Window and/or its Grid is loaded. But the following code either inside the constructor MainWindow(){...} or inside rootGrid_Loadded(...) event throws the error shown below: Question : How can we have the issue resolved and have the HTML string loaded right after either the Window or the Grid is loaded? Or

Binding to StaticResource with a property of View Model in Xamarin.Forms?

走远了吗. 提交于 2020-08-08 05:20:13
问题 I have some custom fonts defined in ResourceDictionary <Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Fonlow.VA.App"> <Application.Resources> <ResourceDictionary> <OnPlatform x:TypeArguments="x:String" x:Key="SuperFont"> <On Platform="Android" Value="Super.ttf#Super" /> <On Platform="UWP" Value="/Assets/Super.ttf#Super" /> <!--<On Platform="iOS" Value="OpenSans-Bold" />--> </OnPlatform> <OnPlatform x:TypeArguments="x

VS2015 WPF Debugging Black Toolbar

久未见 提交于 2020-08-07 09:22:03
问题 I've noticed some toolbar is appearing when I debug WPF applications from VS2015, but I have no idea what it is. It is annoying. What is it? Can I disable it? 回答1: It's XAML debugging tools. The controls are under the Tools - Options menu. Related: Introducing the UI debugging tools for XAML General, Debugging, Options Dialog Box 来源: https://stackoverflow.com/questions/37148078/vs2015-wpf-debugging-black-toolbar

VS2015 WPF Debugging Black Toolbar

风格不统一 提交于 2020-08-07 09:21:32
问题 I've noticed some toolbar is appearing when I debug WPF applications from VS2015, but I have no idea what it is. It is annoying. What is it? Can I disable it? 回答1: It's XAML debugging tools. The controls are under the Tools - Options menu. Related: Introducing the UI debugging tools for XAML General, Debugging, Options Dialog Box 来源: https://stackoverflow.com/questions/37148078/vs2015-wpf-debugging-black-toolbar

How to get {x:DataType} for a DataTemplate in C# for custom DataTemplateSelector

十年热恋 提交于 2020-08-07 04:20:14
问题 I'm writing a custom DataTemplateSelector for a ComboBox control and I'll need to use it to display different DateTemplates for different kind of objects, in both the closed and open modes for the ComboBox . Here's the DataTemplateSelector I came up with: public class ComboBoxTypedDataTemplateSelector : DataTemplateSelector { public IEnumerable<DataTemplate> SelectedTemplates { get; set; } public IEnumerable<DataTemplate> DropDownTemplates { get; set; } protected override DataTemplate

How to get {x:DataType} for a DataTemplate in C# for custom DataTemplateSelector

。_饼干妹妹 提交于 2020-08-07 04:20:03
问题 I'm writing a custom DataTemplateSelector for a ComboBox control and I'll need to use it to display different DateTemplates for different kind of objects, in both the closed and open modes for the ComboBox . Here's the DataTemplateSelector I came up with: public class ComboBoxTypedDataTemplateSelector : DataTemplateSelector { public IEnumerable<DataTemplate> SelectedTemplates { get; set; } public IEnumerable<DataTemplate> DropDownTemplates { get; set; } protected override DataTemplate

Command binding Unable to cast object of type 'System.Reflection.RuntimeEventInfo' to type 'System.Reflection.MethodInfo'

情到浓时终转凉″ 提交于 2020-08-03 12:03:42
问题 When I wire up my button to a command via XAML, I'm getting a run time error System.Windows.Markup.XamlParseException: Provide value on 'System.Windows.Data.Binding' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeEventInfo' to type 'System.Reflection.MethodInfo'. When I remove the command binding in XAML everything works okay, and my items display etc.. Here is the command binding: Click="{Binding ElementName=MainGrid, Path

Add Custom Rows at the top of DataGrid - WPF

喜欢而已 提交于 2020-07-31 01:08:49
问题 I am new in WPF and I have a project that needs to have this output below Do you have any idea on how to do this. I just know a basic dataGrid code like this below <DataGrid AutoGenerateColumns="False" Name="myGrid" Margin="10"> <DataGrid.RowHeaderTemplate> <DataTemplate> <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}, Path=Item.Header}"/> </DataTemplate> </DataGrid.RowHeaderTemplate> <DataGrid.Columns> <DataGridTextColumn Header

Run vs. Content vs. Text in WPF

余生颓废 提交于 2020-07-28 08:58:47
问题 In a WPF (or even a Windows 8 or 8.1 application) you have three possible ways to add a text in a control. Run element inside TextBlock element <TextBlock> <Run>My text</Run> </TextBlock> Text property as attribute of TextBlock element <TextBlock Text="My text" /> Text property as element inside TextBlock element <TextBlock> <TextBlock.Text>my text</TextBlock.Text> </TextBlock>` What are the differences between these three approaches? And why you must use Text for a TextBlock and Content for

How can I pass the currently focused element name through a CommandParameter in XAML?

☆樱花仙子☆ 提交于 2020-07-23 07:32:21
问题 In my WPF MVVM application I want to be able to undo changes to individual TextBox elements using the Esc key. I've set up a command for this and I want to trigger it through XAML thus: <Window.InputBindings> <KeyBinding Command="{Binding EscKeyCommand}" CommandParameter="{Binding FocusManager.FocusedElement}" Gesture="ESC" /> </Window.InputBindings> The idea is that the CommandParameter passes the ElementName of the currently focussed TextBox (if indeed that's what's in focus) and the