应用标题样式模板时 silverlight 列标题消失
我有一个包含两列的 Silverlight DataGrid
。这两个列标题的标题必须与文本框和列标题标题或名称一起显示,以便稍后可以使用文本框进行过滤。
因此,我使用以下代码来使用样式显示文本框:
<Style x:Name="mytemplate"
x:Key="mytemplate"
xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="ContentTemplate" >
<Setter.Value>
<DataTemplate x:Name="ColHeaderTemplategrid">
<StackPanel>
<TextBox x:Name="txtfilterBox" KeyDown="txtfilterBox_KeyDown" Width="40"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
并且我已将样式应用到列标题,如下所示:
((DataGridTextColumn)column[0]).HeaderStyle = mytemplate;
((DataGridTextColumn)column[1]).HeaderStyle = mytemplate;
问题是,现在文本框可见,但列标题标题或名称消失了?
如何与文本框一起显示列标题?
I have a Silverlight DataGrid
with two columns. The headers of these two columns header have to be shown with a text box and column header title or name so that the text box can be used for filtering later.
So, I have used the following code to display the text box using a style:
<Style x:Name="mytemplate"
x:Key="mytemplate"
xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
TargetType="dataprimitives:DataGridColumnHeader">
<Setter Property="ContentTemplate" >
<Setter.Value>
<DataTemplate x:Name="ColHeaderTemplategrid">
<StackPanel>
<TextBox x:Name="txtfilterBox" KeyDown="txtfilterBox_KeyDown" Width="40"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
and I have applied the style to the column headers as below:
((DataGridTextColumn)column[0]).HeaderStyle = mytemplate;
((DataGridTextColumn)column[1]).HeaderStyle = mytemplate;
The thing is, now the text box is visible but the column header title or name disappears?
How do I show my column header along with the text box?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如你所说,我刚刚将文本块插入到模板的堆栈面板中并解决了问题,
代码如下
As u said i just inserted textblock in to the stackpanel of the template and solves the problem
the code is below