Skip to content

Instantly share code, notes, and snippets.

@Keyros
Created May 28, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keyros/8154d407abefe1978ccf to your computer and use it in GitHub Desktop.
Save Keyros/8154d407abefe1978ccf to your computer and use it in GitHub Desktop.
Пример 1
using System.Windows.Controls;
namespace TerstWpfApp
{
/// <summary>
/// Логика взаимодействия для MyUserControl.xaml
/// </summary>
public partial class MyUserControl : UserControl
{
public MyUserControl()
{
InitializeComponent();
}
public double TextBlockWidth
{
get { return TextBox.Width; }
set { TextBox.Width = value; }
}
}
}
<UserControl x:Class="TerstWpfApp.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBox Name="TextBox"></TextBox>
</Grid>
</UserControl>
<Window x:Class="TerstWpfApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:terstWpfApp="clr-namespace:TerstWpfApp"
Title="MainWindow"
Height="350"
Width="525">
<Grid>
<terstWpfApp:MyUserControl Name="MyUserControl">
</terstWpfApp:MyUserControl>
</Grid>
</Window>
using System.Windows;
namespace TerstWpfApp
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void Tmp()
{
this.MyUserControl.TextBlockWidth = 1234.0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment