开发者

how to disable whole view in wpf

I am working on a WPF application in MVVM pattern.

My application consists of 2 modules. The first Module consists of a View. In bottom row of that View I am adding another Region in which another module loads its own View.

Issue: whenever user makes any changes in the upper view, the Lower view (loaded by another module) should gets kind of disabled.

How to achieve this? Is there any way t开发者_开发百科o disable whole view?


XAML UIs are hierarchies of elements and disabling any element by setting IsEnabled to false also disables all of its contained children. If you need to keep things like scrollbars or tooltips enabled you'll need more fine grained IsEnabled settings.


Would "View.IsEnabled = false" be enough?


You could put another control in your view that would lay over top of the rest of it when your view model is loading.

For instance, if your view is in the 2nd row of a table, you could also put a Border that will take up the whole row while loading so the user couldn't do anything while it's visible. IsWorking below would just be a property in your view model you set when you start loading data or are doing anything that you don't want the user to use the control.

<Grid>
   <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
   </Grid.RowDefinitions>

   <myviews:View1 Grid.Row="0" />

   <myviews:View2 Grid.Row="1" />
   <Border Background="#30505050" 
           Grid.Row="1"
           Visibility="{Binding Path=IsWorking, Converter={x:Static CommonConverters:BooleanToVisibilityConverter.Default}}"/>
</Grid>

You could also put the Border into your own control or user control if you wanted to do more with it like adding animations that'll play while working.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜