控件内部的JavaFX 2.0呈现控件 [英] JavaFX 2.0 render controls inside control

查看:88
本文介绍了控件内部的JavaFX 2.0呈现控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.net WPF.使用该库,我可以完全重新设计每个控件. F.e. -我有一个按钮,在按钮内,我可以用行和列渲染表(网格).然后,在表格(网格)中的特定编码上,我可以渲染图像,标签或其他内容.

I work with .net WPF. Using this library allow me to completely redesign every control. F.e. - I've button, inside button I can render table (grid) with rows and columns. Then on specific cordination in table (grid) I can render image, label or something else.

这是重新设计ListBoxItem的示例

here is the example for redesign ListBoxItem

        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Grid x:Name="ShortCutGrid"
                          Height="96" 
                          HorizontalAlignment="Left"                               
                          VerticalAlignment="Top" 
                          Width="96"                              
                          Background="Transparent">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="96"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid Grid.Row="0">
                                    <Image Grid.Column="1" Name="Image1" Width="48" Height="48" Source="{Binding Path=ImageName}"/>
                                </Grid>
                                <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <Label>
                                        <TextBox Background="Transparent" 
                                                 x:Name="TextBox1" 
                                                 Text="{Binding Path=Text}" 
                                                 Foreground="Black" 
                                                 TextWrapping="WrapWithOverflow" 
                                                 TextAlignment="Center"
                                                 BorderThickness="0"
                                                 IsReadOnly="True"
                                                 Focusable="False"
                                                 Cursor="Arrow">
                                        </TextBox>
                                    </Label>
                                </StackPanel>
                            </Grid>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="TextBox1" Property="Background" Value="Navy"/>
                                <Setter TargetName="TextBox1" Property="Foreground" Value="White"/>
                                <Setter TargetName="Image1" Property="OpacityMask" Value="{StaticResource ShortcutSelected}"/>                                    
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <EventSetter Event="MouseDoubleClick" Handler="listBoxItem_DoubleClick" />
        </Style>

我的问题是:在JavaFX 2.0中是否可以在另一个控件中呈现控件 在fxml中?

My question is : Is possible in JavaFX 2.0 to render controls inside another control in fxml?

推荐答案

使用基本控件,它不是.但是您可以编写自己的控件,其中可以包含任何节点.

With the basic controls, it isnt. But you can compose your own controls which can contain contains any node.

这篇关于控件内部的JavaFX 2.0呈现控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆