Q:

WPF Set border left and width

I need to set the left and width of a border.   I'm trying to use margin 
b.Margin = new Thickness(pb. X, b.Margin. Top, b.Margin. Right, b.Margin. Bottom);

but if I set the Width property the border is placed in an incorrect strange position... (the half screen + half of the left that i want). 
how can i do the trick? 
thanks

A:

var totalAvailableWidth = ...; // you will have to get it somewhere
var marginRight = totalAvailableWidth - pb. X - width;
b.Margin = new Thickness(pb. X, b.Margin. Top, marginRight, b.Margin. Bottom);

