小编XAM*_*MAX的帖子

WPF ListView虚拟化分组

有没有人知道在启用分组时支持UI虚拟化的ListView实现?默认情况下,在设置分组时禁用VirtualizingStackPanel.

看来微软不打算在.NET Framework的v4.0中实现这一点,所以我正在寻找替代解决方案.

.net wpf virtualization performance listview

7
推荐指数
2
解决办法
6927
查看次数

如何将UpdateSourceTrigger的值移交给UserControl或在运行时更新它?

我面临UpdateSourceTrigger属性的问题。我有一个名为LabelWithTextBox的UserControl,其中未定义UpdateSourceTrigger(文本属性)(因此具有默认值)。由于性能,它应该保持这样(当Focus不在TextBox中时,Text应该更新)。

但是现在我有一种情况,应该使用UserControl并根据用户类型进行更新,因此我想将UpdateSourceTrigger设置为PropertyChanged。

理想情况下,最好的解决方案是可以继承UpdateSourceTrigger属性。用户在其视图中使用UserControl并定义UpdateSourceTrigger = PropertyChanged,此信息将移交给我的UserControl,并且一切正常。有人知道我可以将其存档吗?

我还有什么其他选择?如何在运行时更改UpdateSourceTrigger属性?

这是相关的UserControl(隐藏代码)代码:

public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
    "Text",
    typeof(string),
    typeof(LabelWithTextBox),
    new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));

public string Text
{
    get { return (string)this.GetValue(TextProperty); }
    set { this.SetValue(TextProperty, value); }
}
Run Code Online (Sandbox Code Playgroud)

这是UserControl(Xaml)代码:

<Grid Grid.Column="1">
            <telerik:RadWatermarkTextBox TextChanged="TextBoxBase_OnTextChanged"
                                         Name="TextBox"
                                         Text="{Binding Text, Mode=TwoWay, ElementName=userControl}"
                                         WatermarkContent="{Binding Placeholder, Mode=TwoWay, ElementName=userControl}"
                                         TextWrapping="{Binding TextWrap, Mode=TwoWay, ElementName=userControl}"
                                         AcceptsReturn="{Binding AcceptsReturn, Mode=TwoWay, ElementName=userControl}"
                                         VerticalScrollBarVisibility="{Binding VerticalScrollBarVisibility, Mode=TwoWay, ElementName=userControl}"
                                         MinLines="{Binding MinLines, Mode=TwoWay, ElementName=userControl}"
                                         MaxLines="{Binding MaxLines, Mode=TwoWay, ElementName=userControl}"
                                         IsReadOnly="{Binding IsReadOnly, ElementName=userControl}"/>
    ....
Run Code Online (Sandbox Code Playgroud)

如果将UpdateSourceTrigger = PropertyChanged添加到Text,一切将按预期工作。但是我不想要那样。

例如,这是某人如何在其视图中使用UserControl的方法。我正在寻找的是一种将UpdateSourceTrigger的值移交给我的UserControl的方法,但是如何?

<controls:LabelWithTextBox
                    Grid.Row="1"
                    Margin="0,5,0,0" …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml user-controls telerik

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

堆栈面板中的水平对齐问题

当我在堆栈面板中添加 2 个文本块时,文本块的 Horizo​​ntalAlignment 设置不起作用

这是什么原因?

Xml:

<Border Grid.Column="1" Background="#312a28">
    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
        <TextBlock Name="current_page" Text="ÖZET" VerticalAlignment="Center" Foreground="White" FontSize="16"/>
        <TextBlock Name="next_page" Text="KASA" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="White" FontSize="16"/>
   </StackPanel>
</Border>
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml

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

标签 统计

wpf ×3

c# ×2

xaml ×2

.net ×1

listview ×1

performance ×1

telerik ×1

user-controls ×1

virtualization ×1