小编Aha*_*our的帖子

如何从另一个类或窗口访问WPF中的控件

我想在WPF中的mainWindow中访问我的控件,如按钮或文本框,但我不能这样做.

在Windows窗体应用程序中它很容易,您可以将该控件的修饰符设置为True,并且您可以从该mainWindow的实例到达该控件,但在WPF中,我无法声明公共控件.我怎样才能做到这一点?

c# silverlight wpf

12
推荐指数
3
解决办法
6万
查看次数

重新设计用户界面后,QtDesigner更改将丢失

我在QtDesigner中使用QtDesinger设计GUI,在QtDesigner中设计我想要的UI后,将其转换为python代码,然后我改变生成的代码在我的python代码中执行一些操作,但是如果我用QtDesigner更改了UI再次将其转换为python代码,我在代码上丢失了以前的更改.

我该如何解决这个问题?

我们可以在python中传播多个文件的类来编写其他文件中的代码吗?

python pyqt qt-designer pyqt5

3
推荐指数
2
解决办法
1147
查看次数

如何在 WPF 单选按钮(如复选框)中设计样式

我想要一个类似于复选框的单选按钮,所以我在字典文件中定义了一个样式,如:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:WpfCheckBoxLikeRadiobutton">

<Style x:Key="MyRadioButton" TargetType="{x:Type RadioButton}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RadioButton}">
                <Grid>
                    <CheckBox
                        IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                        Path=IsChecked, Mode=TwoWay}"
                        IsHitTestVisible="False" />
                    <CheckBox
                    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                    Path=IsChecked, Mode=TwoWay}" Opacity="0"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

并像这样将其合并到 app.xaml 文件中

<Application x:Class="WpfCheckBoxLikeRadiobutton.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:WpfCheckBoxLikeRadiobutton"
         StartupUri="MainWindow.xaml">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Dictionary1.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

然后在我的窗口中使用它

<GroupBox Margin="5" Padding="5">
        <StackPanel >
            <CheckBox Content="this is checkbox" />
            <RadioButton Content="this is first radio button" Style="{DynamicResource MyRadioButton}"/>
            <RadioButton Content="this is Second radio button" Style="{DynamicResource …
Run Code Online (Sandbox Code Playgroud)

wpf checkbox xaml templates styles

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

标签 统计

wpf ×2

c# ×1

checkbox ×1

pyqt ×1

pyqt5 ×1

python ×1

qt-designer ×1

silverlight ×1

styles ×1

templates ×1

xaml ×1