wpf - How to diplay/call an UserControl from another UserControl at click both situated in one MainWindow (C#/Xaml) -


I'm fine, I explain my problem and what I want. I have main window in my solution ; I call first user control in that Main Wando UserControlLibrary . I want a menu with the I'ts button when I first click on the first button of user control, the Visibility of Second User Control is Visible . userControlLibrary ). But I try many things but no one does the work.

The first user control is UC_MenuSlider and the UC_Start_Study is the second one that must be visible after first clicking on a button. Launch UC_Start_Study is hidden .

This is my menu window :

  & lt; Grid name = "Main grid" & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "*" /> & Lt; /Grid.ColumnDefinitions> & Lt; UserControlLibrary: UC_StartStudy x: Name = "UC_Start_Study" grid. Column = "1" height = "auto" width = "auto" margin = "70 0 0 0" visibility = "hidden" /> & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column deflection width = "0.1 *" maxvuth = "240" minway = "240" /> & Lt; Column width = "*" /> & Lt; /Grid.ColumnDefinitions> & Lt; UserControlLibrary: UC_MenuSlider x: Name = "UC_MenuSlider" grid. Column = "0" /> & Lt; / Grid & gt; & Lt; / Grid & gt;   

A part of the code for my first UserControl (UC_MenuSlider)

  & lt; Grid name = "grid_menu" horizontal alignment = "muscles" & gt; & Lt; Grid.RowDefinitions & gt; & Lt; Roadfinion height = "*" /> & Lt; /Grid.RowDefinitions> & Lt; Button x: name = "start_range" grid. Line = "0" grid Column = "0" margin = "0" content = "start study" fontism = "16" click = "start_stida_click" & gt; & Lt; / Button & gt; & Lt; / Grid & gt;   

First of all, a fundamental event, only one event clicks on my first user control with the code behind it:

  Public Zero Start_Study_Click (Object Sender , RoutedEventArgs e) {var startStudy = New UserControlLibrary.UC_StartStudy (); StartStudy.Visibility = Visibility Visible; }   

do not work

I hope my question was quite clear, thanks in advance for your envelope

< Div class = "post-text" itemprop = "text">

The problem is that you are creating a new UC_StartStrudy and its Visibility to Visible Set to . What you really need is to set visibility in one of your XAML : UC_Start_Study

  public Zero Start_Study_Click (Object Sender, Routing Avenger, ARG E) {UC_Start_Study.Visibility = Visibility. Visible; }   

and you can use XML in your UC_StartStrudy of the visibility property database, and its value set in its code Can:

XML:

  & lt; window. Resources & gt; & Lt; BooleanToVisibilityConverter x: key = "BooltoVisible" /> & Lt; /Window.Resourse> ..... & lt; UserControlLibrary: UC_StartStudy x: Name = "UC_Start_Study" grid. Column = "1" height = "auto" width = "auto" margin = "70 0 0" visibility = "{binding IsUCStartStudyVisible, converter = {static resorso bulovisible}}" />   

code (remember to apply):

  // Apply InputifyPropertyChanged Public Event PropertyChangedEventHandler PropertyChanged; Private Zero RisePropertyChange (string propertyName = "") {If (PropertyChanged! = Null) {PropertyChanged (New, PropertyChangedEventArgs (propertyName)); }} // Property for private property bool _isucstartstudyviewable = property; Set up the Public Bull ISUCistStudioViewables {Returns_UKestustivibil;} {_isucstartstudyviewable = value; RaisePropertyChange ("IsUCStartStudyVisible");}} // Your Visual Visibility Public Zero Start_Study_Click (Object Sender, RoutedEventArgs e) {IsUCStartStudyVisible = true; }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -