首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹出在DataGrid (xceed)内部不绑定到Toggle (Xceed)

弹出在DataGrid (xceed)内部不绑定到Toggle (Xceed)
EN

Stack Overflow用户
提问于 2018-11-08 11:21:51
回答 1查看 67关注 0票数 0

我做了一个Toggle,它扩展了一个弹出式窗口,里面有一个ListBox。看起来是这样的:

代码语言:javascript
复制
<ToggleButton Name="Toggle" Height="20" Width="150" >
    <StackPanel>
        <TextBlock Text="TestListPopup"/>
        <Popup Height="200" Width="150"
                            IsOpen="{Binding ElementName=Toggle, Path=IsChecked}"
                            PlacementTarget="{Binding ElementName=Toggle}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Bottom">
            <ListBox SelectionMode="Multiple" SelectionChanged="TypeSelectionChanged" >
                <ListBoxItem Content="Test1"/>
                <ListBoxItem Content="Test2"/>
                <ListBoxItem Content="Test3"/>
            </ListBox>
        </Popup>
    </StackPanel>
</ToggleButton>

它工作得很好,但是我想在我的xceed FilterRowDataGrid中使用它:

代码语言:javascript
复制
<xcdg:DataGridControl x:Name="dataGrid"
                      ItemsSource="{Binding Source={StaticResource DataSource}}">
    <xcdg:DataGridControl.View>
        <xcdg:TableflowView>
            <xcdg:TableflowView.FixedHeaders>
                <DataTemplate>
                    <xcdg:ColumnManagerRow/>
                </DataTemplate>
                <DataTemplate>
                    <xcdg:FilterRow>
                        <xcdg:FilterCell FieldName="Name" IsEnabled="True"/>
                        <xcdg:FilterCell FieldName="Type" IsEnabled="True">
                            <!--  TestListPopup control here  -->
                        </xcdg:FilterCell>
                    </xcdg:FilterRow>
                </DataTemplate>
            </xcdg:TableflowView.FixedHeaders>
        </xcdg:TableflowView>
    </xcdg:DataGridControl.View>
    <xcdg:DataGridControl.Columns>
        <xcdg:Column FieldName="Name" Title="Name" />
        <xcdg:Column FieldName="Type" Title="Type" Width="160"/>
    </xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>

但是在这里,弹出窗口将不会绑定到切换按钮。按下按钮什么也做不了。

我将范围缩小到绑定被破坏,因为如果您设置IsOpen="True",它是打开的(而不是依附于PlacementTarget),但还是一样;它在DataGrid之外工作得非常好。

为什么一个功能完善的控件一旦放入FilterRow就会中断呢?

如有任何帮助,将不胜感激!)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-08 12:50:54

为什么一个功能完善的控件一旦放入FilterRow就会中断呢?

因为ToggleButtonFilterCell不属于同一个显象管

您可以尝试使用x:Reference绑定

代码语言:javascript
复制
IsOpen="{Binding Path=IsChecked, Source={x:Reference Toggle}}"

另一个选项是将ToggleButtonToggleButton属性绑定到视图模型的bool属性,并将PopupIsOpen属性绑定到相同的源属性。确保视图模型实现INotifyPropertyChanged接口,并在设置源属性时引发更改通知。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53206739

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档