问题描述
大家好,
我在WPF UI级别编程方面表现不佳,我被困在某处可以看到一些控件或动态启用/禁用。
我的WPF(XAML)的当前设计如下: -
< Canvas x:Name =" MainCanvas" AllowDrop =" False">
&NBSP; < Rectangle Fill =" White" X:名称= QUOT; rBackground" AllowDrop =" False">< / Rectangle>
&NBSP; < Border BorderBrush ="#FF928682"了borderThickness = QUOT; 1,1,0,0" x:名称=" bMain1" />
&NBSP; < Border BorderBrush =" Black"了borderThickness = QUOT; 0,0,1,1" x:名称=" bMain2" />
&NBSP; <标签x:名称=" oFLabel"高度= QUOT; 10" />
&NBSP; < core:Tv10Button Width =" 25"高度= QUOT; 25" Canvas.Top = QUOT; 12英寸Canvas.Right = QUOT; 2英寸X:名称= QUOT; btnAdd"的ImageSource = QUOT; /Images/PL_ADDITEM.png" />
&NBSP; < core:Tv10Button Width =" 25"高度= QUOT; 25" Canvas.Top = QUOT; 40" Canvas.Right = QUOT; 2英寸X:名称= QUOT; btnRem"的ImageSource = QUOT; /Images/PL_DELETEITEM.png" />
&NBSP; < core:Tv10DBCtrlGrid x:Name =" repeater"
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; ScrollViewer.VerticalScrollBarVisibility =" Visible"
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; VirtualizingStackPanel.IsVirtualizing =" False"
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; AlternationCount =" {x:Static sys:Int32.MaxValue}">
&NBSP; &NBSP; < ListBox.ItemTemplate>
&NBSP; &NBSP; &NBSP; < DataTemplate>
&NBSP; &NBSP; &NBSP; &NBSP; < Canvas />
&NBSP; &NBSP; &NBSP; < / DataTemplate>
&NBSP; &NBSP; < /ListBox.ItemTemplate>
&NBSP; < / core:Tv10DBCtrlGrid>
&NBSP; < Canvas x:Name =" cDataTemplateEditor" &NBSP;的AllowDrop = QUOT;真" &NBSP;背景= QUOT;白色" >
&NBSP; &NBSP; < Border BorderBrush =" Black"了borderThickness = QUOT 1 QUOT; x:Name ="< g class =" gr_ gr_73 gr-alert gr_spell ContextualSpelling ins-del multiReplace"数据-GR-ID =" 73" ID = QUOT; 73"> bTemplate< / g取代;"
AllowDrop =" True" />
&NBSP; < / Canvas>
< / Canvas>
我们在运行时设计控件,
grid 相同的控件容易显示(true / false)和启用/禁用但是当我们在网格内部采用相同的控件并按照与外部网格相同的方式分配值时,所有控件都可见并且始终启用。
当我们制作画布" cDataTemplateEditor "时可见和网格中继器隐藏的比所有表现都要好,如:
cDataTemplateEditor.Visibility = Visibility.Visible;
repeater.Visibility = Visibility.Hidden;
但通过这种方式,我们失去了一项功能,实际上,我们要求将相同的控件用作行并添加行多次根据客户需要。为此,我们更改了网格和画布可见性。如下所述:
cDataTemplateEditor.Visibility = Visibility.Hidden;
repeater.Visibility = Visibility.Visible;
由于Grid(转发器)画布内的所有控件绘制都会失去其可见性或启用/禁用值。
请建议我错过了什么。
(我找不到合适的小组发布我的问题,以便我选择使用论坛)。
谢谢,
Kapil Khare
Hi All,
I'm not good in WPF UI level programming, I'm stuck somewhere to make some controls visible or Enable/disable Dynamically.
Current Design of my WPF (XAML) is below mentioned:-
<Canvas x:Name="MainCanvas" AllowDrop="False">
<Rectangle Fill="White" x:Name="rBackground" AllowDrop="False"></Rectangle>
<Border BorderBrush="#FF928682" BorderThickness="1,1,0,0" x:Name="bMain1"/>
<Border BorderBrush="Black" BorderThickness="0,0,1,1" x:Name="bMain2"/>
<Label x:Name="oFLabel" Height="10" />
<core:Tv10Button Width="25" Height="25" Canvas.Top="12" Canvas.Right="2" x:Name="btnAdd" ImageSource="/Images/PL_ADDITEM.png" />
<core:Tv10Button Width="25" Height="25" Canvas.Top="40" Canvas.Right="2" x:Name="btnRem" ImageSource="/Images/PL_DELETEITEM.png" />
<core:Tv10DBCtrlGrid x:Name="repeater"
ScrollViewer.VerticalScrollBarVisibility="Visible"
VirtualizingStackPanel.IsVirtualizing="False"
AlternationCount="{x:Static sys:Int32.MaxValue}">
<ListBox.ItemTemplate>
<DataTemplate>
<Canvas/>
</DataTemplate>
</ListBox.ItemTemplate>
</core:Tv10DBCtrlGrid>
<Canvas x:Name="cDataTemplateEditor" AllowDrop="True" Background="White" >
<Border BorderBrush="Black" BorderThickness="1" x:Name="<g class="gr_ gr_73 gr-alert gr_spell ContextualSpelling ins-del multiReplace" data-gr-id="73" id="73">bTemplate</g>" AllowDrop="True" />
</Canvas>
</Canvas>
We design control at run time, out side grid same controls easily make visible(true/false) and Enable/disable but when we take same controls inside the grid and assign a value as the same way as used out side grid but all controls are visible and enable always.
when we make canvas "cDataTemplateEditor" to visible and Grid repeater is hidden than all perform well as required like:
cDataTemplateEditor.Visibility = Visibility.Visible;
repeater.Visibility = Visibility.Hidden;
but through this way, we lose one functionality, actually, we have a requirement to use same control as a row and add rows so many times as per client need. for this, we change grid and canvas visibility. as below mentioned like:
cDataTemplateEditor.Visibility = Visibility.Hidden;
repeater.Visibility = Visibility.Visible;
Due to this all control draw inside Grid(repeater) canvas loose their visibility or enable/disable values.
Please suggest me what I missed.
(I don't find proper group to post my question so that I choose Using Forums).
Thanks,
Kapil Khare
Thanks, Kapil Khare
这篇关于WPF网格控制可见性相关问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!