小编Rya*_*yan的帖子

在WPF中获取"<Property Name>"已在"<Control Name>"中注册错误

我在WPF中有一个用户控件,它具有绑定到依赖属性.当我尝试编译应用程序时,我得到一个"属性名称"已经被"ControlName"错误注册,并且设计者显示"无法创建"用户控件"错误的实例.

这是我的简单控件的样子:

ExampleUserControl.xaml:

<UserControl x:Class="ExampleApp1.ExampleUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:ExampleApp1"
             mc:Ignorable="d" >

    <TextBox Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ExampleUserControl}}, Path=SomeStringValue}" />

</UserControl>
Run Code Online (Sandbox Code Playgroud)

ExampleUserControl.xaml.cs:

public partial class ExampleUserControl : UserControl
{

    public DependencyProperty SomeStringValueProperty = DependencyProperty.Register("SomeStringValue", typeof(string), typeof(ExampleUserControl));
    public string SomeStringValue
    {
        get
        {
            return GetValue(SomeStringValueProperty) as string;
        }
        set
        {
            SetValue(SomeStringValueProperty, value);
        }
    }

    public ExampleUserControl()
    {
        InitializeComponent();
    }
}
Run Code Online (Sandbox Code Playgroud)

它托管的主窗口:

<Window x:Class="ExampleApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ExampleApp1"
        Title="MainWindow" Height="350" Width="525">

    <StackPanel>
        <local:ExampleUserControl SomeStringValue="Test 1" />
        <local:ExampleUserControl SomeStringValue="Test 2" />
    </StackPanel>

</Window>
Run Code Online (Sandbox Code Playgroud)

这是设计师的样子:

设计师错误的屏幕截图

以下是XAML设计师的样子: XAML

c# wpf xaml dependency-properties

15
推荐指数
2
解决办法
5477
查看次数

Telerik RadTileList控件的布局问题

虽然我已经在这个问题上向Telerik提交了支持票,但我也在这里发布了一个问题,希望有人可以找到解决方案:

RadTileList控件在tile的顶部和底部添加额外的填充.为了证明这一点,我创建了一个包含三个tile的简单WPF应用程序.该应用程序包含一个包含在红色边框内的Telerik RadTileList控件(用于显示控件的开始和结束位置),RadTileList包含三个硬编码的Telerik Tiles.其中两个是"单一"大小的瓷砖,另一个是"双".我要做的是让瓷砖对齐控件的左上角.

以下是xaml:

<Window x:Class="TelerikRadTileListIssue.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="522" Width="559">

    <Border BorderBrush="Red" BorderThickness="2">
        <telerik:RadTileList >
            <telerik:RadTileList.Items>
                <telerik:Tile TileType="Single">
                    <TextBlock>Tile 1</TextBlock>
                </telerik:Tile>

                <telerik:Tile TileType="Double">
                    <TextBlock>Tile 2</TextBlock>
                </telerik:Tile>

                <telerik:Tile TileType="Single">
                    <TextBlock>Tile 3</TextBlock>
                </telerik:Tile>

            </telerik:RadTileList.Items>
        </telerik:RadTileList>

    </Border>
</Window>
Run Code Online (Sandbox Code Playgroud)

测试应用的屏幕截图

wpf telerik

5
推荐指数
1
解决办法
3146
查看次数

SQL Server 2014 Express安装程序未创建Configuration.ini文件

我正在尝试创建一个"Configuration.ini"文件来自动化未来的SQL Server Express 2014安装.我找到了来自整个网络的几个帖子,告诉我正常安装,选择我的所有设置,在准备安装之前,屏幕左侧的"准备安装"文本将是粗体,底部将有一个TextBox,其中包含配置文件的路径.事实证明,这些都没有显示在屏幕上,并且安装程序没有创建Configuration.ini文件.为什么不为我创建.ini文件?

installation sql-server-2014-express

3
推荐指数
1
解决办法
3201
查看次数

启用或禁用按钮时,如何更改自定义按钮中标签的前景色?

给定以下带有自定义内容的WPF按钮,如何在启用按钮时使用触发器将其标签的前景颜色更改为蓝色,并在禁用按钮时将其更改为红色?

<Window x:Class="CustomButtonTriggerExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
            <Button IsEnabled="{Binding ElementName=chkEnabled, Path=IsChecked}">
                <StackPanel Orientation="Horizontal">
                    <Label VerticalContentAlignment="Center">This is a label control inside a button</Label>
                    <Image Height="50" Width="50" Source="/CustomButtonTriggerExample;component/Images/Some Image.png" Stretch="Fill" />
                </StackPanel>
            </Button>
            <CheckBox x:Name="chkEnabled">Button Enabled</CheckBox>
        </StackPanel>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

wpf triggers styles button isenabled

1
推荐指数
1
解决办法
1425
查看次数

在 C# 中获取任何扩展文件属性

我正在尝试找到一种方法来获取 C# 中 COM DLL 的扩展文件属性(特别是“产品版本”)。我在 MSDN 上找到了一些通过添加“Microsoft Shell Controls and Automation”COM 参考来使用 Shell32 的示例,但文档似乎有些含糊。有没有一种简单的方法可以做到这一点?

例如:采用 C:\Windows\Notepad.exe 的以下属性:

记事本.exe 的属性

我想以编程方式获取 C# 中的“产品版本”属性。顺便说一句,这可以是任何文件,但是,我只是使用 Notepad.exe,因为它是一个通用示例

c#

1
推荐指数
1
解决办法
2885
查看次数