xaml

The name does not exist in the namespace in WPF application

℡╲_俬逩灬. 提交于 2020-02-05 06:54:33
问题 Creating a WPF application, using VS2017. I have an enum like: namespace Sample.Common { public enum SmPageTypes { Type1 = 0, Type2 = 1 } } I'm trying to use it in xaml form, but get an error: The name "SmPageTypes" does not exist in the namespace "clr-Sample.Common;assembly=Sample". Here is xaml code adding namespace: xmlns:CommonAlias="clr-namespace:Sample.Common;assembly=Sample" and add enum as resource: <Window.Resources> <ObjectDataProvider x:Key="dataFromEnum" MethodName="GetValues"

changing contents of a grid in wpf dynamically

a 夏天 提交于 2020-02-05 06:41:06
问题 I am trying to change the contents of a grid dynamically using usercontrol.My mainWindow.xaml looks like this. <Window x:Class="testapp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="524" Width="856"> <Grid Background="Black"> <!--<Image Height="44" HorizontalAlignment="Left" Margin="284,0,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="229" Source="/testapp

Change listbox template on lost focus event in WPF

我怕爱的太早我们不能终老 提交于 2020-02-05 04:54:46
问题 I want to present a listbox with TextBlocks as items. When the user clicks/selects an item it changes into a TextBox for editing. As soon as the controls loses focus the item would turn back to a TextBlock. The following XAML is almost working in that the TextBlock does turn into a TextBox when it's selected. It also turns back to a TextBlock if I select another item on the list. The problem is that if I move out of the listbox (in this case to the Add New text box) the list item stays as a

DataBinding to a UserControl inside of a UserControl [duplicate]

爱⌒轻易说出口 提交于 2020-02-05 04:47:12
问题 This question already has answers here : WPF - Should a user control have its own ViewModel? (5 answers) How to correctly bind to a dependency property of a usercontrol in a MVVM framework (4 answers) Closed 2 years ago . In my project, I need to DataBind to a UserControl that resides in another UserControl. For the sake of brevity, I created a conceptually similar but very simple project. Imagine that I am creating a Phone Book application, with two user controls in it, that looks like below

WPF学习笔记:XAML入门

青春壹個敷衍的年華 提交于 2020-02-04 11:57:29
1、什么是XAML XAML是WPF技术中专门用于设计UI的语言,它在桌面开发及富媒体网络程序的开发中扮演了HTML+CSS+JAVASCRIPT的角色,成为设计师和程序员之间沟通的桥梁。它帮助开发团队真正实现了UI与逻辑的分离。 2、解析最简单的XAML代码 我们新建一个WPF项目,然后打开UI设计界面,代码如下: <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> </Grid> </Window> 我们看到有很多属性名为xmlns的属性

少量代码设计一个登录界面(二) – .NET CORE(C#) WPF开发

依然范特西╮ 提交于 2020-02-04 11:36:14
原文: 少量代码设计一个登录界面(二) – .NET CORE(C#) WPF开发 微信公众号: Dotnet9 ,网站: Dotnet9 ,问题或建议: 请网站留言 , 如果对您有所帮助: 欢迎赞赏 。 阅读导航 本文背景 代码实现 本文参考 源码 1. 本文背景 同上篇文章《少量代码设计一个登录界面》,本篇介绍另一种登录界面设计风格。 2. 代码实现 使用 .NET CORE 3.1 创建名为 “Login” 的WPF模板项目,添加1个Nuget库:MaterialDesignThemes.3.1.0-ci981。 解决方案主要文件目录组织结构: Login App.xaml MainWindow.xaml MainWindow.xaml.cs 2.1 App.xaml文件引入样式 文件【App.xaml】,在 StartupUri 中设置启动的视图【MainWindow.xaml】,并在【Application.Resources】节点增加 MaterialDesignThemes库的样式文件: <Application x:Class="Login.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx

少量代码设计一个登录界面(二) – .NET CORE(C#) WPF开发

跟風遠走 提交于 2020-02-03 15:44:36
微信公众号: Dotnet9 ,网站: Dotnet9 ,问题或建议: 请网站留言 , 如果对您有所帮助: 欢迎赞赏 。 阅读导航 本文背景 代码实现 本文参考 源码 1. 本文背景 同上篇文章《少量代码设计一个登录界面》,本篇介绍另一种登录界面设计风格。 2. 代码实现 使用 .NET CORE 3.1 创建名为 “Login” 的WPF模板项目,添加1个Nuget库:MaterialDesignThemes.3.1.0-ci981。 解决方案主要文件目录组织结构: Login App.xaml MainWindow.xaml MainWindow.xaml.cs 2.1 App.xaml文件引入样式 文件【App.xaml】,在 StartupUri 中设置启动的视图【MainWindow.xaml】,并在【Application.Resources】节点增加 MaterialDesignThemes库的样式文件: <Application x:Class="Login.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml">

少量代码设计一个登录界面 - .NET CORE(C#) WPF开发

℡╲_俬逩灬. 提交于 2020-02-03 14:18:48
原文: 少量代码设计一个登录界面 - .NET CORE(C#) WPF开发 微信公众号: Dotnet9 ,网站: Dotnet9 ,问题或建议: 请网站留言 , 如果对您有所帮助: 欢迎赞赏 。 少量代码设计一个登录界面 - .NET CORE(C#) WPF开发 阅读导航 本文背景 代码实现 本文参考 源码 1. 本文背景 继续 MaterialDesignThemes 开源控件库学习,本文简单使用输入控件的水印附加属性:materialDesign:HintAssist.Hint。 2. 代码实现 使用 .NET CORE 3.1 创建名为 “Login” 的WPF模板项目,添加1个Nuget库:MaterialDesignThemes.3.1.0-ci981。 解决方案主要文件目录组织结构: Login App.xaml MainWindow.xaml MainWindow.xaml.cs 2.1 App.xaml文件引入样式 文件【App.xaml】,在 StartupUri 中设置启动的视图【MainWindow.xaml】,并在【Application.Resources】节点增加 MaterialDesignThemes库的样式文件: <Application x:Class="Login.App" xmlns="http://schemas.microsoft

Interaction Triggers Embedded in ContentControl

半腔热情 提交于 2020-02-03 09:02:57
问题 So to keep the question simple what I need for example is to use something like this dozens of times; <Rectangle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="AnotherObjectOnTheView" PropertyName="Visibility" Value="Visible" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> Except obviously I don't want to paste that dozens of times everywhere I need it. So I tried to plop them in a ContentControl , something like

Interaction Triggers Embedded in ContentControl

大兔子大兔子 提交于 2020-02-03 09:01:07
问题 So to keep the question simple what I need for example is to use something like this dozens of times; <Rectangle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="AnotherObjectOnTheView" PropertyName="Visibility" Value="Visible" /> </i:EventTrigger> </i:Interaction.Triggers> </Rectangle> Except obviously I don't want to paste that dozens of times everywhere I need it. So I tried to plop them in a ContentControl , something like