xaml

Binding Run inside Textblock results in exception in WPF

时间秒杀一切 提交于 2020-08-27 03:39:36
问题 I'm trying to bind two <Run> s inside a TextBlock as shown in the snippet below. But I'm getting an XamlParseException . Basically I'm trying to achieve this format: CodeNum: LongDescription If the below code is doomed to fail what other alternatives do I have? <TextBlock> <Run FontWeight="Bold" Text="{Binding CodeNum}"/> <Run FontWeight="Bold" Text=": "/> <Run Text="{Binding LongDescription}"/> </TextBlock> 回答1: I'm guessing that either LongDescription or CodeNumis is a read-only property

Binding ZIndex from DataTemplate

爱⌒轻易说出口 提交于 2020-08-25 03:52:08
问题 I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl ItemsSource="{Binding MyItems}" ItemTemplate="{Binding Source={StaticResource MyItemsDataTemplate}}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </Grid> </ViewBox> </Grid> The DataTemplate used here can be reduced to this: <DataTemplate x:Key="AreaItemDisplayDataTemplate"> <Canvas Grid.ZIndex={Binding Z}> <Grid> // an shape is

Binding ZIndex from DataTemplate

你离开我真会死。 提交于 2020-08-25 03:51:45
问题 I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl ItemsSource="{Binding MyItems}" ItemTemplate="{Binding Source={StaticResource MyItemsDataTemplate}}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </Grid> </ViewBox> </Grid> The DataTemplate used here can be reduced to this: <DataTemplate x:Key="AreaItemDisplayDataTemplate"> <Canvas Grid.ZIndex={Binding Z}> <Grid> // an shape is

Multiple DataGrid columns with the same custom template/style but different binding/context

梦想的初衷 提交于 2020-08-24 03:27:05
问题 I would like to create a custom DataGrid column (or a DataGridCell style), ideally in XAML, and use it multiple times without any code duplication. It should contain multiple different controls, each accessing a different property of the data object. There seem to be two ways of doing this: DataGridTemplateColumn with a custom CellTemplate (see an example here) custom DataGridCell style (something like this or this) Both of these solutions suffer from the same issue. When specifying the

Loading a WPF control embedded in a DLL in runtime

懵懂的女人 提交于 2020-08-23 09:11:17
问题 In my WPF project, I have a dll that contains several WPF UserControls. I would like, in runtime, to be able to check a parameter in the database (already implemented) and according to that parameter (which is a string) to be able to load a specific UserControl to my View. The UserControl is actually a Canvas, so it basically just places the correct Canvas on the View according to the database entry. I don't know if I was clear, so please ask me if you didn't understand the question. Thanks

Loading a WPF control embedded in a DLL in runtime

[亡魂溺海] 提交于 2020-08-23 09:09:24
问题 In my WPF project, I have a dll that contains several WPF UserControls. I would like, in runtime, to be able to check a parameter in the database (already implemented) and according to that parameter (which is a string) to be able to load a specific UserControl to my View. The UserControl is actually a Canvas, so it basically just places the correct Canvas on the View according to the database entry. I don't know if I was clear, so please ask me if you didn't understand the question. Thanks

WPF: Using a Virtual Keyboard

杀马特。学长 韩版系。学妹 提交于 2020-08-23 08:02:08
问题 I have created a virtual keyboard user control to use across multiple windows within my application. I am wondering how I am able to get it to input into a textbox in a window when a key is pressed. What I am looking for is something like: private void keyboardKey_Click(object sender, RoutedEventArgs e){ var key = sender as Button; textbox.Text += key.Content; } So for example, if I press the key for 'a', then 'a' is added to the textbox. My mind tends towards some sort of binding property

Xamarin forms MasterDetailPage Menu icon not shown on iOS

旧时模样 提交于 2020-08-23 05:27:09
问题 I have Xamarin.Forms project. I have MasterDetailPage inside NavigationPage. I set icon property of the MasterDetailPage so that icon is supposed to be set as the top left position on the navigation bar. But it does not work. public partial class App : Application { public App() { InitializeComponent(); var masterDetailpage = new MasterDetailPage { Icon = "menuIcon.png", Master = new Page { Title = "Sample"}, Detail = new Page() }; MainPage = new NavigationPage(masterDetailpage); } } This

How to Invert Color of XAML PNG Images using C#?

霸气de小男生 提交于 2020-08-22 21:03:23
问题 I'm using Visual Studio, C#, XAML, WPF. In my program I have XAML buttons with white png icons. I want to have it so you can switch to a theme with black icons by choosing the theme from a ComboBox. Instead of creating a new set of black png images, is there a way with XAML and C# I can invert the color of the white icons? <Button x:Name="btnInfo" HorizontalAlignment="Left" Margin="10,233,0,0" VerticalAlignment="Top" Width="22" Height="22" Cursor="Hand" Click="buttonInfo_Click" Style="

How to style the slider control in WPF?

浪尽此生 提交于 2020-08-22 06:39:30
问题 I want to style the slider control so that the height of the draggable thumb is set to 8 pixels. What is the simplest way to do this in WPF? <Slider> <Slider.Style> <!-- which xaml here? --> </Slider.style> </Slider> 回答1: The Slider Control has many parts Thumb, RepeatButtons and a Track. It is one of those controls that have named elements, like PART_Track, referenced by the code-behind for it to work correctly. A good starting point is to use Blend to help you out. Start a new project (or