WPF网格控制可见性相关问题。 [英] WPF Grid Control visibility related issue.

查看:51
本文介绍了WPF网格控制可见性相关问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在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 













<谢谢,Kapil Khare

解决方案

我只能建议您阅读有关数据绑定的内容。还有WPF布局。此外,因为你使用自己的控件(我认为它是一个ListBox?),很难在不知道它是什么的情况下提供帮助。


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

解决方案

I can only suggest that you read about databinding. Also WPF layout. Also since you are using your own control (I think it is a ListBox?) it is hard to help without knowing what it is.


这篇关于WPF网格控制可见性相关问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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