if(pictureBox1.Bounds.IntersectsWith(pictureBox2.Bounds))
{
// put your code here
}
Imposter syndrome disclaimer: I want your help. No really, I do.
There might be a little voice inside that tells you you're not ready; that you need to do one more tutorial, or learn another framework, or write a few more blog posts before you can help me with this project.
<TextBox Text="{Binding Greeting, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap" />
public class SimpleVM : INotifyPropertyChanged
{
private string greeting;
public string Greeting
{
get { return greeting; }
set
{
greeting = value;
OnPropertyChanged(nameof(Greeting));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName]string prop = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
}
}
<ItemsControl Grid.Column="0" ItemsSource="{Binding Greeting}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox IsReadOnly="True" Text="{Binding .}"
Width="20" Foreground="Black"
BorderThickness="1" BorderBrush="Black" Height="23"
Background="{x:Null}" Margin="1, 3" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
public MainWindow()
{
InitializeComponent();
DataContext = new SimpleVM();
}
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding SearchCommand}" />
</TextBox.InputBindings>
public class SomeObject
{
public bool WasClicked { get; set; }
public MapObject2 Object { get; }
public SomeObject(MapObject2 mobj)
{
Object = new MapObject2(mobj);
}
}
if (index == -1)
break;
static int StringCounter(string s1, string s2)
{
int count = 0;
int index;
while (true)
{
index = s1.IndexOf(s2);
if (index == -1)
return count;
s1 = s1.Substring(index + s2.Length);
count++;
}
}
button1.Click += button1_Click;
button2.Click += button2_Click;
<Image Width="100" Height="75" IsEnabled="False"
Source="{Binding Path= ImageList}" />
<Image Width="100" Height="75" IsEnabled="False"
Source="{Binding}" />
public class Gallery
{
private string directoryPath; // Путь к каталогу
public IEnumerable<string> LinksToPictures { get; } // Названия файлов
public Gallery(string directoryPath)
{
this. directoryPath = directoryPath;
LinksToPictures = Directory.GetFiles(directoryPath, "*.jp*g");
}
}
ItemsSource="{Binding LinksToPictures}"
public MainWindow()
{
InitializeComponent();
DataContext = new Gallery("F://");
}
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Settings>
<PathToFile>"C:\Users\1234\Desktop\start.bat"</PathToFile>
</Settings>
<Settings>
<PathToFile>"C:\Users\1234\Desktop\start2.bat"</PathToFile>
</Settings>
</root>
var path = "Settings.xml"; // путь к файлу настроек
var batName = "start.bat";
var xdoc = XDocument.Load(path);
var batPath =
xdoc
.Descendants("PathToFile") // ищем элементы PathToFile
.SingleOrDefault(xe => xe.Value.Contains(batName)); // ищем единственный из них содержащий нужный bat файл
if (batPath == null) // если в файле нет нужного пути
{
MessageBox.Show("Путь не указан"); // сообщаем пользователю
}
else // иначе
{
Process.Start(batPath.Value.Trim('"')); // запускаем процесс
}
<Button Command="{Binding OpenDataBaseEditorView}">Open</Button>
<Application.Resources>
<SolidColorBrush x:Key="solidGrayBrush" Color="Gray" />
<TextBlock
Background="{DynamicResource solidGrayBrush}"
Text="Test" />
Brush[] brushes =
typeof(Brushes)
.GetProperties()
.Select(p => (Brush)p.GetValue(null))
.ToArray();
Random r = new Random();
private void Button_Click(object sender, RoutedEventArgs e)
{
var b = brushes[r.Next(brushes.Length)];
Application.Current.Resources["solidGrayBrush"] = b;
}
<Application.Resources>
<!--<ResourceDictionary Source="/DataGridThemes;component/ExpressionLight.xaml" />-->
<!--<ResourceDictionary Source="/DataGridThemes;component/ExpressionDark.xaml" />-->
<ResourceDictionary Source="/DataGridThemes;component/WhistlerBlue.xaml" />
</Application.Resources>